ASP.NET - is there any possible way to retain value in Page_Init event..

Asked By anbu n on 01-Mar-12 10:19 AM

in below Page_Init event

the values are not available in controls

txtRows.Text  &  txtCols.Text are empty. the value comes only after page _load event

protected void Page_Init(object sender, EventArgs e)
    {

       this.Rows = Int32.Parse(txtRows.Text);
        this.Columns = Int32.Parse(txtCols.Text);

}

--------------

is there any possible way to retain value in Page_Init event....

vinod kumar replied to anbu n on 01-Mar-12 10:37 AM

hope this link helps you..

http://forums.asp.net/p/1775616/4859116.aspx/1?Re+is+there+any+possible+way+to+retain+value+in+Page_Init+event+



Robbe Morris replied to vinod kumar on 01-Mar-12 11:23 AM
Really?  A link that just points to another search you typed in?
kalpana aparnathi replied to anbu n on 01-Mar-12 01:42 PM
hi,

One another idea for getting value before page_load event in page_init event is to use control which have viewstate property so it not affect the value of text boxes and get your desired results.

Hope will works!!!!!!!!!

Regards,
vinod kumar replied to Robbe Morris on 02-Mar-12 12:47 AM
sorry, that link wrongly pasted..
Robbe Morris replied to anbu n on 02-Mar-12 08:20 AM
It looks like you may be trying to create dynamic controls on your page based off of the Rows and Columns properties.  This link will help you with that:

http://www.eggheadcafe.com/tutorials/asp-net/1fde7294-de3c-45f7-8c4c-df711ff6e1e7/aspnet-dynamic-textbox--dropdownlist-control-viewstate-to-store-namevaluecollection.aspx