类别:前端知识
日期:2023-10-24 浏览:1680 评论:0
<script language="javascript" type="text/javascript"> // var lpServerIP = "192.168.2.180";//硬盘录像机ip // var lPort = 8001; // var lpUserName = "admin"; // var lpPassword = "12345"; // var lChannelNum = 2; var lpServerIP = "<%=getIpServerIP()%>";//硬盘录像机ip var lPort = "<%=iPort %>"; var lpUserName = "<%=getlpUserName()%>"; var lpPassword = "<%=getlpPassword()%>"; var lChannelNum = "<%=iChannelNum %>"; var UserID function Play() { var i; var Netocx = document.getElementById("NetOCX"); UserID = Netocx.Login(lpServerIP,lPort,lpUserName,lpPassword); i = Netocx.StartRealPlay(lChannelNum,0, 0); if (i == 0) { alert("预览失败!"); } } function Stop() { var Netocx = document.getElementById("NetOCX"); Netocx.StopRealPlay(); Netocx.Logout(); } function FullScreen() { var Netocx = document.getElementById("NetOCX"); Netocx.FullScreenCtrl(); } function Play1() { var Netocx1 = document.getElementById("NetOCX1"); UserID = Netocx1.Login("172.7.76.85",8000,"admin","12345"); Netocx1.StartRealPlay(0 ,0, 0); } function Stop1() { var Netocx1 = document.getElementById("NetOCX1"); Netocx1.StopRealPlay(); Netocx1.Logout(); } </script>
后台cs
public partial class _Default : System.Web.UI.Page { public int iPort; public int iChannelNum; string ipServerIP = ""; string ipUserName = ""; string ipPassword = ""; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //获取参数 if (Request.QueryString["ID"] != null && Request.QueryString["Flag"] != null) { string id = Request.QueryString["ID"].ToString(); string flag = Request.QueryString["Flag"].ToString(); DataSet ds = this.getVideoUrl(Convert.ToInt32(flag),Convert.ToInt32(id)); //获取具体参数 string startTimeStr = ds.Tables[0].Rows[0]["StartTime"].ToString(); string endTimeStr = ds.Tables[0].Rows[0]["EndTime"].ToString(); //判断时间范围 DateTime startTime = Convert.ToDateTime(startTimeStr); DateTime endTime = Convert.ToDateTime(endTimeStr); DateTime dtNow = DateTime.Now.ToLocalTime(); if (dtNow > startTime && endTime > dtNow || dtNow == startTime || dtNow == endTime) { string ip = ds.Tables[0].Rows[0]["DvrIP"].ToString(); string userName = ds.Tables[0].Rows[0]["UserName"].ToString(); string pwd = ds.Tables[0].Rows[0]["Pwd"].ToString(); string ChanelNumber = ds.Tables[0].Rows[0]["ChanelNumber"].ToString(); string[] ipStr = ip.Split(':'); ipServerIP = ipStr[0]; iPort = Convert.ToInt32(ipStr[1]); ipUserName = userName; ipPassword = pwd; iChannelNum = Convert.ToInt32(ChanelNumber); //iChannelNum = 1;//用来测试 } else { Response.Write("<script lauguage = javascript>window.alert('当前时间未能访问,谢谢!');window.location.href='error.htm';</script>"); } } else { Response.Redirect("error.htm"); } } } /// <summary> /// 获取网站视频调用url /// </summary> /// <param name="flag">访问权限,2为家长</param> /// <param name="userID">访问用户ID</param> /// <returns>数据集</returns> protected DataSet getVideoUrl(int flag,int userID) { string cmd = "exec spGetVideoUrlByFlagID "+flag+","+userID; return Common.SqlHelper.ExecuteDataSet(cmd); } protected string getIpServerIP() { //string lpServerIP = "192.168.2.180";//硬盘录像机ip return ipServerIP; } protected string getlpUserName() { //string lpUserName = "admin";//用户名 return ipUserName; } protected string getlpPassword() { //string lpPassword = "12345";//密码 return ipPassword; } public static bool IsWindowsVistaOrNewer { get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major >= 6); } } }
二,js获取Session
<script language="javascript" type="text/javascript"> function getUrl() { var id = '<%=Session["fbt.ParentID"] %>'; var flag = "2"; var strUrl = "VideoTest/OsInfo.aspx?ID="+id+"&Flag="+flag; window.location.href = strUrl; //alert(strUrl); }
本文标题:Js获取C#后台方法,变量及Session
本文链接:https://vtzw.com/post/1105.html
版权声明:本文不使用任何协议授权,您可以任何形式自由转载或使用。
发表评论 / 取消回复