1、将要获取的值用public属性公开,然后在js中用变量var xx = <%= PubProperty %>
2、将值保存到一个html控件的属性中,这个属性可以自定义,例如<input type="text" );

 

 

 

例如:在aspx.cs中定义属性 ,要Page_Load()事件中要给这个属性赋值

    public string CurrentID
        {
            get { return ViewState["currID"] == null ? string.Empty : (string)ViewState["currID"]; }
            set { ViewState["currID"] = value; }
        }

 

在 js中取值 的方法

A方法:

function OpenWindow()
        {
            var currid = <%= CurrentID %>
           // var strUrl = "AddProduct.aspx?cateId="+document.activeElement.getAttribute("cateid");
            var strUrl = "AddProduct.aspx?cateId="+document.getElementById('btnAddProduct').getAttribute("cateid");
            window.open(strUrl,"Product","statusbar=yes,width=600px,height=550px,top=0,left=0");
        }

 

B:方法;在一个Html控件中自定义一个属性 cateid

<input   /></div>

 

  function OpenWindow()
        {
            
           //a var strUrl = "AddProduct.aspx?cateId="+document.activeElement.getAttribute("cateid");
            //b  var strUrl = "AddProduct.aspx?cateId="+document.getElementById('btnAddProduct').getAttribute("cateid");
            window.open(strUrl,"Product","statusbar=yes,width=600px,height=550px,top=0,left=0");
        }

a,b 都可以取得此值

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-09-17
  • 2022-03-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案