使一个button先执行后台的Click再执行javascript的onclick
HTML:
<script type="text/javascript"> function openEg(); </script> <body> <asp:Button ID="btnsel" runat="server" Text="查询" onclick="btnsel_Click" /> </body>
后台代码:
protected void btnsel_Click(object sender, EventArgs e) { //如果有UpdatePanel就用如下代码调用前台js ScriptManager.RegisterStartupScript(UpdatePanel1,this.Page.GetType(), "", "if(confirm('确认添加么')){document.getElementById('hdf_MC').value='yes'}", true; //如果没有,写code ClientScript.RegisterStartupScript(Page.GetType(), "ww", "if(confirm('确认添加么')){document.getElementById('hdf_MC').value='yes'}", true); }