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

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");
}

----------------------------------------------------------------------------
 
N

Natty Gur

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
 
S

SSW

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top