`
cpsing
  • 浏览: 71130 次
  • 来自: ...
最近访客 更多访客>>
社区版块
存档分类
最新评论

JavaScript$$c#

阅读更多

C#中如何调用Javascript函数?

在.cs页面中使用javascript函数,例子  
  string   indexpage="XXX.aspx";  
  Response.Write("<script>");  
  Response.Write("parent.frames[1].location.href='indexpage'");        
  Response.Write("</script>");  
 

服务器端调用脚本函数  
  写一个javascript  
  function   test()  
  {  
    alert("ok");  
  }  
   
  如果控件是runat=server的话,那么就在那个Button1.attribute["onkeypress"]="javascript:test()";  
  html控件:  
  就行了


Response.Write("<script   language="javascript">function1()</script>")

aspx里的代码:  
  function   test(){  
  }  
   
  在aspx.cs的page_load写下代码:  
  Button1.attribute["click"]="javascript:test()";  
   
  或者  
  Button1.attribute.Add("click","test()");  
   

Page.RegisterStartupScript("("<script   language="javascript">function1()</script>");  
  楼上的方法也可行。 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics