Page_Load事件 [英] Page_Load event

查看:82
本文介绍了Page_Load事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我创建了一个Web用户控件.我在其中添加了DropDownList.我已经处理了用户控件的Page_Load事件.加载包含我的用户控件的页面时,将调用Page_Load处理程序.但是,当我更改用户控件中dropdownList中的选定值时,将再次调用用户控件的page_load处理程序,并且将刷新用户控件中的所有值.我无法弄清楚这个问题.

请帮助我.

Hi
I have created a web user control. I added DropDownList in it. I have handled the Page_Load event of my user control. The Page_Load handler is called when the page containing my user control is loaded. But when i change the selected value in the dropdownList in my user control the page_load handler of my user control is called again and all the values in my user control are refreshed. I can not figure out this problem.

Please help me.

推荐答案

如果您的页面刷新,则会调用事件,这是为什么呢?
If your page refreshes, the events are called, why is this an issue ?


检查IsPostBack属性后的下拉列表,

Bind the dropdown after checking IsPostBack property,

if(!IsPostBack)
{
  BindDDL();
}



我想这会解决您的问题.



I think this will solve your problem.


我认为Arun Jacob是正确的.

问题可能是,每次您绑定下拉列表时.而是仅在首次加载页面时绑定.如果问题没有解决,请回复.
I think Arun Jacob is right.

The problem might be, every time you bind your drop down list. Instead bind only when page loads first time. Reply if the problem not solved.


这篇关于Page_Load事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆