Latest Development Blogs
Forum Topics Post
Browse By Tag
I have put ServerBinding WebGrid in a asp.net UserControl (.ascx).
The UserControl has properties that I normally maintain State with ViewState.
I also maintain State in an asp:TextBox.
I have found that between WebGrid CallBacks, such as an Add Row, if I make changes to the UserControl Properties, maintained by ViewState, the values do not stick.
I have tried the ControlState but it does not make a difference.
The only solution I have found is to maintain State in a Session Variable which I would prefer not to do since this would be the only Session Variable that I use in the application.
I found some articles that about "To work around this issue, I simply repeated the call to WebForm_InitCallback before starting the out-of-band call"
Is there something to configure for the WebGrid to make it maintain ViewState or do you have any other ideas as to how to maintain State in this situation?
According to our developer, the earliest server side event will be control load server side event. For example in ASP TextBox it will be during OnLoad server side event handler.
Our control callback is named FlyPostBack. During FlyPostBack, in order to set value you will need to use RenderControl function. Here is an example to set a value during postback for TextBox. Here is the snippet:
TextBox1.Text = "New Value;";wgTest.ClientAction.RenderControl(TextBox1);
If the suggestion does not solve your issue, do you mind sending us a simple sample of the issue?
That was half the answer.
Since I was using an asp:TextBox, I also had to set FlyBackSettings.PostInputControls to true.
Where can I find the default values for FlyBackSettings?
You could read about FlyPostBack in more detail on the article "How-to: Improve FlyPostBack performance" in the WebUI Framework 3 documentation.
The default setting of FlyPostBack is also discussed in the article.
What is the earlist Server Side Event that I can get the value from the asp:TextBox that has been loaded by the FlyPostBack.
Could you elaborate on the scenario you are trying to achieve? As far as I understand, the textbox value will be ready after invoking the RenderControl function.
I have prepared a simple sample in which the textbox value will be inserted with the newly added row and retrieve during a button click using flypostback.
In ASP.Net there is a Page Life Cycle. On PostBacks, ViewState is loaded in the LoadViewState, after Initialization and before LoadPostbackData.
My understanding is the FlyPostBack is probably doing something like an XMLHttpRequest.
When FlyPostBackSettings PostInputControls or PostHiddenFields is set to true, I am guessing you have to Package up these values in your XMLHttpRequest call. That means you have to Unpackage this data on the Server so the Control Values are available.
Since you have the customize the XMLHttpRequest to pass control Values to the Server, I am guessing you are not using the LoadViewState, but some other Customized Server Event to Unpackage the data.
What is the Event Sequence (Life Cycle) of an FlyPostBack and where is the Control Values associated with FlyPostBackSettings unpackaged on the Server?
What is the earliest that these FlyPostBackSettings Control Values are available Server Side on any FlyPostBack? I am not necessarily talking about when used with a RenderControl ClientAction. If you want to bring the RenderControl into the scenario I don't mean on that FlyPostBack it would on subsequent FlyPostBacks, just like with or without a RenderControl.
Discover WebUI Studio® 2012
Get Started with WebUI Studio®
WebUI Studio® Edition
For ASP.NET Development
For Silverlight Development
For WPF Development
Learn More About ClientUI