Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 27, 2012 11:36 AM by karthicks
Member
17 Points
85 Posts
Apr 27, 2012 11:29 AM|LINK
here in below code protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } else { createdynamictable();//to create dynamic table with textbox } } protected void btnCalculate_OnClick(object sender, EventArgs e) { createdynamictable();//to create dynamic table with textbox } --------------------------------------- in the above code if method --- createdynamictable() is called only in button click[not in Page.IsPostBack of Page_load]... then the values entered is lost
C#.net
All-Star
32146 Points
5530 Posts
Apr 27, 2012 11:36 AM|LINK
hi, dynamic controls should be recreated on each and every postback to retain it's state.
Refer :http://www.4guysfromrolla.com/articles/081402-1.aspx
http://weblogs.asp.net/infinitiesloop/archive/2006/08/25/TRULY-Understanding-Dynamic-Controls-_2800_Part-1_2900_.aspx
http://support.microsoft.com/kb/317515
http://www.codeproject.com/Articles/3684/Retaining-State-for-Dynamically-Created-Controls-i
anbujeremiah
Member
17 Points
85 Posts
Page_Load event vs button click event
Apr 27, 2012 11:29 AM|LINK
here in below code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
else
{
createdynamictable();//to create dynamic table with textbox
}
}
protected void btnCalculate_OnClick(object sender, EventArgs e)
{
createdynamictable();//to create dynamic table with textbox
}
---------------------------------------
in the above code if method --- createdynamictable() is called only in button click[not in Page.IsPostBack of Page_load]... then the values entered is lost
C#.net
karthicks
All-Star
32146 Points
5530 Posts
Re: Page_Load event vs button click event
Apr 27, 2012 11:36 AM|LINK
hi, dynamic controls should be recreated on each and every postback to retain it's state.
Refer :http://www.4guysfromrolla.com/articles/081402-1.aspx
http://weblogs.asp.net/infinitiesloop/archive/2006/08/25/TRULY-Understanding-Dynamic-Controls-_2800_Part-1_2900_.aspx
http://support.microsoft.com/kb/317515
http://www.codeproject.com/Articles/3684/Retaining-State-for-Dynamically-Created-Controls-i
C#.net
Karthick S