Reputation: 11
I have created a User Control(Popupcontrol) and in that control i have created a property(PageType) and when i am using the Popupcontrol on the page then i set the property(pagetype) according to the page. but now there is some problem i have to two button on the page and on the second button click i want to change the pagetype property .So is there any solution for the same.
Upvotes: 0
Views: 132
Reputation: 32323
Based on your comment, it seems you bind the data (PageType
property in your question) in the Page_Load
event, instead of this it should be done in overrided DataBind
method which should be called if the page is not in post back request (otherwise your data will be overwritting in the next Page_Load
event as you mentioned in your comments):
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
DataBind();
}
}
public override void DataBind()
{
PageType = someValue;
}
after this your click handler may looks like:
protected void button2_Clicked(object sender, EventArgs e)
{
PageType = someOtherValue;
}
Upvotes: 1
Reputation: 12979
Are you setting the variable in a page load event? You may need to add:
if (!Page.IsPostback) {
// Code here.
}
Upvotes: 0