LoadViewState works only when datagrid or datalist control not when TextBoxa and other server contro

  • Thread starter Thread starter SSW
  • Start date Start date
S

SSW

Hi:

In aspx.cs page i had written the code below. I have a button control and
only create TextBox Control dynamically. LoadViewState is Never called.

But when we put datagrid/DataList it works. Can any one help me with this?

Thanks,

SSW
MCSD, MCAD, OCA
----------------------------------------------------------------------------
----------------------------------------------------------------------------

Code
----------------------------------------------------------------------------
----------------------------------------------------------------------------
protected override void LoadViewState(object savedState)
{
Reponse.Write("In LoadViewState");
base.LoadViewState(savedState);
BindControl(); /// A function to create dynamic Controls...
Response.Write("SDFSDF");
}

----------------------------------------------------------------------------
 
Hi,

I'll try. LoadViewState works just if the server side control save data
to the view state. if data saved to the view state on the next post back
LoadViewState will be called to get the control data store in view
state. if you will add for example this line
this.ViewState.Add("f","g");
LoadViewState will be called since you add data to view state. Every
control that can pass its data via Form (Post), which mean all server
side control that render to variations of INPUT tag, don’t need to store
data in view state since their data is passed inside the Form
collections. That’s the reason that textbox didn’t cause LoadViewState.


HTH

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
Thanks for ur reply.

But when we make TextBox Server control Visible attribute false at that time it stores in view state and it call's LoadViewState.

Thanks for ur help :)

sswalia
MCSD, MCAD, OCA
 
Back
Top