[英]user control button click in asp.net
I have user control file cust_list.ascx 我有用户控制文件cust_list.ascx
i have added this control to my aspx page. 我已经将此控件添加到我的aspx页面。 have two buttons in my aspx page.. 我的aspx页面中有两个按钮。
during page_load I displayed 5 controls.. 在page_load期间,我显示了5个控件。
when i click on next button.it will show next 5 controls...i have previous button too. 当我单击下一步按钮时,它将显示接下来的5个控件...我也有上一个按钮。
my problem is when in click on button which is in user control after next button click the page set back to initial state.which is having situation same as when the first time page was loaded.but button_click in user control doesnt fire. 我的问题是在单击用户按钮中的下一个按钮后,将页面设置回初始状态。这与第一次加载页面时的情况相同,但是用户控件中的button_click不会触发。
The below link might help you 以下链接可能对您有帮助
https://stackoverflow.com/a/9080243/546033 https://stackoverflow.com/a/9080243/546033
There instead of HtmlGenericControl
use your control like Button
那里而不是HtmlGenericControl
使用像Button
这样的控件
Or else you need to load the user-control at Page_Load
OR Page_Init
so that the control events get registered like 否则,您需要在Page_Load
或Page_Init
处加载用户控件,以便控件事件像
Page_Load(object sender,EventArgs e)
{
createControls();
}
make sure to keep the function call out of if(!isPostBack)
as it wont be able to click after postback. 确保将函数调用保持在if(!isPostBack)
因为它在回发后将无法单击。
hope this helps you.... 希望这对您有帮助...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.