Viewing The Size Of The Viewstate On Any Given Postback?
May 4, 2010Is there a reliable method for viewing the size of the viewstate on any given postback?
View 3 RepliesIs there a reliable method for viewing the size of the viewstate on any given postback?
View 3 RepliesThe values are stored in viewstate fr the postback... Does everysubsequent post back increase the viewstate size?
View 1 Repliesjust wanna ask what is acceptable size of ViewState per page? What is the level I should start worried. Is there any objective measurement for viewstate size?
View 6 RepliesWhere can I see the total size of ViewState out of the total size of the Response (value in bytes in the Body column) in Fiddler 2?
View 5 RepliesI am developing a a web application of a general store where the operator has to enter the things what customer has purchased. Like daily usage item,or anything. So I have form in which I first ask how much item u wannt to register...(if he has 20-30 number of items then operator will enter 20-30 then in gridview 20-30 item are opened. With bind dropdownbox containing name of item ,then textboxs containing mrp, value, stock avail of that item. Here is the link for demo. [URL]. Problem is suppose the operator enter the value above 20, then viewstate size id about 1.50Mb that's too heavy.
[Code]....
Here is .cs code
[Code]....
well what i want to find out is how can i figure out if some change occurd in page when postback , i mean when the first state of the page hahe any changes after postback . I thought maybe somehow to compare viewstaes but i can not find out how can i do that.
View 13 RepliesI have a grid with rows of data, but the page will fail have several postback. I check it with fiddler and find that view state expands 2-3 times after each post back.
The thing I did to trigger the post back is searching and sorting. I am not sure how it happens.
I want to be able to find the old value of a asp.net control (textbox, checkbox etc) without relying on events (e.g. OnTextChange event). Something like "someTextboxControl.OldText" would be perfect! I imagine that it is stored in the viewstate and need to somehow get at it via a custom control.
View 2 RepliesI'm having trouble with a simple radio set of two radio buttons (I don't want to use a RadioButtonList [RBL] because RBL doesn't allow child controls, and in my case, if you select one option, I want to enable a textbox next to the button; yes you could hack this with jQuery to move the textbox, but that's dirty!). I would check one, submit the form (either explicitly or through AutoPostBack), and the CheckedChanged event would never fire. When the page was reloaded, both buttons would be unchecked, regardless of their initial state on non-postback load or the state before form submission.
form id="form1" runat="server" enableviewstate="true">
<div>
<asp:RadioButton ID="foo" Text="foo" runat="server" AutoPostBack="true" OnCheckedChanged="rbChanged" Checked="true" GroupName="foobar" EnableViewState="true" />
<asp:RadioButton ID="bar" Text="bar" runat="server" AutoPostBack="true" GroupName="foobar"
OnCheckedChanged="rbChanged" Checked="false" EnableViewState="true" />
[code]...
I am creating a simple string of values that get added to a label after a post back. I am setting the values thorugh ViewState. However, my appended values do not get updated until AFTER the 2nd postback. Example:
On Page_Load the label displays a "0";
If I enter a "1" in the text box and click the button the label still displays a "0";
If I click the button again (the 2nd postback) then my label correctly displays "0,1"; This works for whatever value I enter after. i.e. "0,1,35,hello world", etc.
What I am I missing? Code Below.
.ascx - I left out inherits and codebehind
[Code]....
Is it necessary to reload the viewstate of usercontrols during postback? I want to know in which case viewstate is set by default.
View 2 RepliesI've got a weird problem with a NullReferenceException on a high traffic website my company hosts. The exceptions are logged with full stack-traces but I am unable to reproduce it.The exception occurs a couple of times a day, for different users, and it's a NullReferenceException thrown in the code block below:
protected void Page_Load(object sender, EventArgs e)
{
...
if (!Page.IsPostBack)
{
...
this.ViewState[StaticClass.StaticStringProperty] = StaticClass.StaticIntProperty; // this is the line the exception occurs on
...
}
}
The only place I can figure that a NullReferenceException would be thrown is if ViewState is NULL, but I've never known that and can't find any reason why this would be the case in a Page_Load that isn't a postback.StaticStringProperty and StaticIntProperty are both initialised, static properties of StaticClass.
StaticStringProperty is defined as:
public const string StaticStringProperty = "IdFromClient";
Does anyone know how this could happen, or any other reason why a NullReferenceException would be thrown on the above line?
EDIT.As requested, the full stack-trace for the error is as follows. Line 54 is the line I've highlighted above.
at MyCompany.MyApplication.Appliance.Page_Load(Object sender, EventArgs e) in C:Documents and SettingsshellamaMy DocumentsMyApplicationAppliance.aspx.cs:line 54
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)[code]....
I've created a Web User Control that is placed on the page at design time. It's purpose is to pop up with a grid of items the user is to choose from. So I've got a gridview on it. And this code in the usercontrol:
Public Property DataTable() As Data.DataTable
Get
If Not IsNothing(ViewState("_SelectGridDataTable")) Then
Return ViewState("_SelectGridDataTable")
Else
Return Nothing
End If
End Get
Set(ByVal value As Data.DataTable)
ViewState("_SelectGridDataTable") = value
End Set
End Property
So when the user clicks on a button on the page, I put this in the code on the page:
SelectGrid2.DataTable = GetContacts().Tables(0)
SelectGrid2.Show()
And this works fine. The grid pops up (using jQuery) and the grid is shown. The problem is, that when the user clicks the "OK" button on the UserControl, the ViewState("_SelectGridDataTable") is always nothing. And I don't get it, since it's in the viewstate.. ?!? So does viewstate here not REALLY mean viewstate?
I am looking for an event firing before a DropdownList auto-postback to save Listbox items (populated with JS) in the ViewState.I tried the OnSelectedIndexChanged event but it's fired too late.
View 5 RepliesI'm reading about the UpdatePanel and how it interacts with controls inside & outside of it.
My understanding is that the usual ASP.Net pipeline takes place when posting from within an UpdatePanel-- Page load etc all fire off as normal-- except when the prerendering stage is reached. In that case the ScriptManager does a final check and only renders those controls within the UpdatePanel and skips the rest. That's my understanding at least.
Sounds good, but for argument's sake let's say I have a TextBox located outside an UpdatePanel. If a postback occurs from within that panel, the TextBox's properties can still be set in the page load method, but those changes will not take effect. (normally; it is possible to postback the entire page from an UpdatePanel)
Is that correct? What happens to that TextBox's ViewState in this instance? Is it updated based on what happened to it in the page load method or is that modification tossed out because it wasn't in the UpdatePanel?
I'm getting some strange behaviour with viewstate being lost on postback for a .net application using Sitecore. I'm assuming it might be some config variable somewhere but I'm new to Sitecore and don't really know where to start looking.
UPDATE: Sitecore has now gotten back to us with an answer. We had recently added the dtSearch module, and AutomaticDataBind was set to true in the dtSearch.config which overrides the setting in the web config. We've now removed it and it works fine again.
I've made a mini test if that might help. It's two usercontrols on one page, both with a repeater. When updating the viewstate gets lost so even if I'm binding the updated repeater again the data for the other one will be lost.
Usercontrol 1:
<asp:Repeater runat="server" ID="Repeater1" OnItemDataBound="Repeater1_ItemBind">
<ItemTemplate>
<li>
<asp:Literal runat="server" ID="Literal1"></asp:Literal>[code]....
what might be going on? Let me know if I need to provide any more information. The most annoying thing is that it was working last week but I have no idea what has changed!
I have a bit of javascript that presents a modal to the user with the rest of the page "grayed out." Pretty common these days. The modal allows you to specify a URL which then uses AJAX to serve and display. What I need is that when the control posts back, it posts back to the parent page, not the modal page. To attempt this, I used javascript to alter the target of the modal page's form element to the parent page's URL. When I try this I get the following error:
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
This is done locally and as of now, the app will never be on a cluster. I think this has to do with the validation process and .NET doesn't like that I've changed the target. Anyone know a way around this? I really need this to work how I described.
When we disabled the viewstate in gridview its lose value but this case not true with Textbox control why?
View 1 RepliesI have "n" <tables></tables> on my page and each <table> has One(1) <asp:CheckBox.. Enable ='true"/> and "x" <asp:TextBox Enabled="false"..>. Each Table looks as follows
[Code]....
When I click checkbox, it calls javascript function and enables textboxes (I have added onclick attribute to checkbox). Page also has <asp:Button ...Text="Submit"/> whcih actually grabs the data from the textboxes on the page and send it to the databse. Here is the Onclick event of the <asp"button../>
[Code]....
If the exception is thrown , textBoxes are not reset but on postback textboxes appear as disabled (values are not reset)
So here is what happening on postback when exception is thrown
1) Values are not reset (that is what want)
2) Texboxes appear as Disabled (that is what I don't want on exception, REMEMBER I enable textBoxes using client side script)
How can I keep the textboxes enabled = "true"
I've build a class like this:
[code]....
The values of this class are set at postback by clicking a radiobutton list. Problem however is I don't know how to save this values across multiple postbacks. I thought of using viewstate but I'm not quite sure how to do it with this class.
Maybe I'm missing some important thing here.
Hope someone can point me in the right direction.
Im currently experincing some difficulties with the viewState. The scenario is that i have a datagrid that has a column of buttons that when pressed will store a value in the viewState. I have already done this on one occasion in the same page, but for some reason the second item in the view state is always returning null, even when i hardcode in a number in before the postback. Im at a loss as to why this is happening, anyone expericened this and know what is wrong.
EDIT: Ive found out the cause, Its due to when you click a button in a data grid it does the postback code first, then fires the event handler, so of course the view state would be empty as it is coded to be set in the event handler for the button click. Is there any way to avoid that? So the event code is fired before the postback code?
I've got a GridView on my page which has some bound controls, one of which is a label (to display total price):
[Code]....
However this value is not being passed to my page. All I see is '£' symbol, no price which makes me think Viewstate["youpay"] is empty? I have enabled viewstate on the Page and Control tags.
What ASP.NET page lifecycle event can I write code in to determine the size of the viewstate that being sent out? Also, is it possible to determine the size without parsing through the rendered HTML (like a property on the page object) or is parsing the only way?
What I'd like to do is log the sizes, specifically if they cross a certain threshold.
My datasource is an ado data table that I have convert to a new data table so that each row in the original table is now a column with 1 row in my new table. I then bind the new datatable and create dynamic template fields with a text box where I bind the values. My problem is, when I try and retrieve the values changed by the user in the rowcommand event, the template columns no longer exists.
Does anyone know how i can retrieve these values? I've read over and over that you have to rebind the grid on each postback when you use dynamic templates, but I'm not sure how to do that and retrieve the values entered in the text boxes on the client side.
[Code]....
I have created a composite control with sample details as follows. Basically, the first time on page load the control sets a view state variable and the problem is that on post back (when the button is clicked), the ViewState variable is null. I have researched extensively and I am not able to find a solution. I checked all the Microsoft recommended articles and also from other developers. This approach seem to work for everyone
PS: This code may not work as it is only for illustrative purposes. but this is exactly what i'm doing in my code.
Public class Test : CompositeControl
{
private Button btnTest = new Button();
public string TestViewState[code]....