首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

怎样才能让按钮事件在js前触发?希望在下班前搞定,该如何处理

2012-02-12 
怎样才能让按钮事件在js前触发?希望在下班前搞定从慈卡中得到ID,通过ID,查看信息。js---------functionWrit

怎样才能让按钮事件在js前触发?希望在下班前搞定
从慈卡中得到ID,通过ID,查看信息。
js
---------
function   WriteToIC()
{
    得到卡号并写入磁卡
    alert(卡号.value);

}
---------
private   void   btn_click(object   sender,System.EventArgs   e)
{
      string   id   =   getIdbyUser(xxxx)得到用户对应的卡号
      btn.   Attributes.Add( "onclick ", "WriteToIC() ");
}
----------
现在问题是js中无法得到卡号,如何让按钮事件比js提早完成?也就是先取到id再执行js中得到卡号的代码。



[解决办法]
vs2005

private void btn_click(object sender,System.EventArgs e)
{
string id = getIdbyUser(xxxx)得到用户对应的卡号
this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "funciton ", " <script language= 'javascript ' defer> 得到卡号并写入磁卡 </script> ");
}
vs2003

private void btn_click(object sender,System.EventArgs e)
{
string id = getIdbyUser(xxxx)得到用户对应的卡号
this.Page.RegisterStartupScript( "funciton ", " <script language= 'javascript ' defer> 得到卡号并写入磁卡 </script> ");
}

[解决办法]
js
---------
function JustWriteToIC(cardNo)
{
写入磁卡
alert(cardNo);

}
---------
private void btn_click(object sender,System.EventArgs e)
{
string id = getIdbyUser(xxxx)得到用户对应的卡号
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "write card_id ",
"WriteToIC( ' "+id.Replace( " ' ", "\\ ' ")+ ") ",true);
}

[解决办法]
用ajax从服务端得到卡号后再显示在页面上
[解决办法]
学习
Mark

热点排行