viewstate

Using custom TypeConverters on complex custom objects that contain generic collections

I have a class, Questionnaire, which contains a collection class that wraps a generic list, EntityCollection. I am using ViewState to persist the Questionnaire and its collection of Questions. I am using custom type converters to reduce the ViewState size. Everything works without a type converter for EntityCollection<T>. Would things...

Inside what the TexBox value is posted back? ViewState or post back data?

In one article I was reading on ViewState, I saw a sentence saying that I should not fall into a mistake to believe that the value of a TextBox is stored in ViewState; it is stored in PostBack data. From here what I understand is when I post back a web form, the input controls values are stored in HTTP Request body. Not in the Viewstate...

Optimizing ViewState

Does anyone have any ideas or references they could point me to regarding optimizing the viewstate of my ASP .NET application? I don't want to turn it off all together, and the main goal of optimizing it is to speed up performance so I don't want to run an expensive function to recursively disable the viewstate for certain controls becau...

Change default value of EnableViewState

I know that with other properties you can define their default value by using skins. But for some reason they won't let me do this for EnableViewState. I don't want EVERYTHING set to EnableViewState="false" I just want them to default to false then if I want them to I can go through and enable them manually. The cleaner the solution th...

find if dropdown value was added dynamically

Is there a way to determine (after a postback) if a value in a dropdownlist has been added dynamically or is one of the initial values? eg. <asp:DropDownList ID="MyDDL" runat="server"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:DropDownList> // on postback 1 private void Ad...

Closing slashes on viewstate tags?

All, I've noticed that asp.net includes a closing slash on the viewstate form field: <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="blah blah blah" /> How can I prevent this from happening? We're rendering html 4.01 strict and this seems to be noncompliant. ...

asp.net mvc clearing a form after post

I'm a .net programmer, but new to mvc. I created a new mvc page with a simple form on it - 2 textboxes and a submit button. Upon posting, it goes to my server side method, where the user info is entered into the db, and then I want to return the user to the same exact form but empty again. When I use "return View("Index", new myIndexOb...

Session State v ViewState

In our application, we have a "BasePage" that declares a number of properties to be used by more or less every page in the app. Inside these properties, they write to ViewState. These are all typically an int or small string value, nothing huge. Typical use is call a web service and hold an id for use within the page, for example. I'v...

Validation of Viewstate MAC failed

I've been getting a validation of viewstate error for a long time on my site that I have yet to be able to reproduce. Based on the user-agents and IP addresses, it seems to mostly be coming from spammers. I've put in multiple fixes (including disabling event and request validation, and moving viewstate hidden fields to top of form) think...

ViewState and refresh

Rather than using the Session object or storing to the database, I am storing temporary variables that I need persisted to custom ViewState variables. For example, ViewState("MyField1") = 1 When the user hits the browser Rrefresh button, Page.IsPostback is back to False and the ViewState is gone. My question is. If the user can blow aw...

Send page by email ViewState issue

Hi, My client wants a page that they can send as an email through IE, but when I do File>Send>Page by Email it adds a hidden input field at the top of the page with some random letters in it. I've been asked to remove it... I've tried EnableViewState=false and removing it from the dom with javascript and even hiding it with CSS but i...

ViewState is not saved across postback the second time the page postsback.

I have an ASP.NET Page that contains a User control called ReportCtrl (my own control that has nothing to do with Reporting services etc.). ReportCtrl has a User control called TreeViewCtrl which contains a Telerik TreeView with some funky business logic to display nodes. The TreeView is placed inside a ASP.NET AJAX panel. When a user ...

Gridview ControlState very large even when viewstate disabled and not using DataKeyNames

Hi, I have an asp:Gridview bound to an asp:ObjectDataSource. I have disabled the ViewState on the GridView, and have not set the DataKeyNames property. I have about 10 BoundFields and a few TemplateFields. These TemplateFields are not bound to server controls but to an anchor tag or to an img tag. However, at runtime, when I switch on ...

Getting Failed to load viewstate error....

First off, I am not dynamically creating any controls. This is the order I take to produce the error: I have a listview on the page, when I click the edit link under the listview, I display a panel which is hidden by default. The panel has a few buttons on it along with some listboxes. When I click an item in the listbox or click one...

ASP.NET Custom Server Control not persisting ViewState

Hello, I have created a custom Server control that processes some data, stores that data to ViewState, and then renders itself from that data. I am using the debugger and can physically see the data getting set to ViewState: public string RawData { get { string result = null; if (ViewState["...

Reducing viewstate size in asp.net

Hai Guys, I use 'n' number of server controls in my page... Now i am into performance tuning and i ve noticed that my viewstate is too large that it makes my page slow... I know viewstate size can be compressed by Gzip... Any other suggestions for reducing viewstate in asp.net.... I dont want to do in IIS because my web application is ...

Can I store xmlDocument object in ViewState?

Hi, I have one XML document which I want to store it inside ViewState so on each post back I do not need to load it from its physical path again. I do not want to store it in SessionState as well. when I tried to srote it in ViewState I get an error: Exception Details: System.Runtime.Serialization.SerializationException: Type 'System....

ViewState in WebService? Is this possible?

according to my research, it isn't possible... unless i write one big hack (erk) to get around it... im wondering if it is possible or not as some of you may have more information on this. i understand this would go against the page paradigm, however it really should be accessible... any ideas anyone? hate using cookies as the informati...

Dynamic Controls State Management - View State Vs Database

Hi All, What is the best option to store data pertaining to dynamic controls. Here is my scenario. At any time around 5 to 15 master tables to retreive from. Dynamic Controls can be of type TextBox, DropDownList, ListBox, GridView. Master's are not going to change on postback, but page will incur many postbacks in a same session. I'm...

C# Custom Serialization - Using TypeConverter

So I need to serialize a generic dictionary like Dictionary<long, List<MyClass>>. I need to serialize it to store it in the ViewState of an ASP.Net application. I found an example of using TypeConverter to convert my class to a string to be serialized, but I get an error message saying MyClass is not marked as serializable. Here is th...