ASP按钮出现问题 [英] Problem with asp button
本文介绍了ASP按钮出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序中,当我单击按钮时,必须单击才能显示一个弹出窗口,但是第二次单击时,弹出窗口就会出现.
这是代码
In my application when i click on button a popup window has to appear for single click but on second click the popup is coming.
here is the code
<asp:Button ID="btnedit"
CssClass="editbtn" BorderWidth="0" Width="46px" Height="20px" runat="server"
onclick="btnedit_Click" />
按钮代码:
btnedit.Attributes.Add("onclick","openemppostingjospopup(""+ Convert.ToInt32(folderid)+"''));
button code:
btnedit.Attributes.Add("onclick", "openemppostingjospopup(''" + Convert.ToInt32(folderid) + "'')");
推荐答案
检查位置您已经放置了"onclick"的代码.
如果它位于if(!Page.IsPostBack)下,则将其移出Page_Load中的if条件.
Check where you have placed the code for "onclick".
If it is under if(!Page.IsPostBack), move it out of that if condition in Page_Load.
您要向同一事件"onclick"添加两个事件处理程序. />
一种是aspx中的-onclick ="btnedit_Click"
其他是-"onclick","openemppostingjospopup(""+ Convert.ToInt32(folderid)+"'')"
因此,请从aspx页面中删除onclick事件.它将起作用.
You are adding two eventhandlers to the same event ''onclick''.
One is -onclick="btnedit_Click" in the aspx
Other is - "onclick", "openemppostingjospopup(''" + Convert.ToInt32(folderid) + "'')"
So remove the onclick event from the aspx page. It will work.
编写您的代码:
write your code :
btnedit.Attributes.Add("onclick", "openemppostingjospopup('" + Convert.ToInt32(folderid) + "')");
内页加载.
它是用按钮单击的事件处理程序方法编写的,这就是为什么回发后打开弹出窗口的原因.
inside page load.
it is written in event handler method of button click, thats why your pop up window is opening after post back .
这篇关于ASP按钮出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文