Manage pages and view your Asp.net page

if I set EnableViewState="false" then also the input data is saved after the postback while using the control, for example

  • text box
  • switch
  • check box
  • and etc.

So, I just wanted to know the bitwise internal things, that if EnableViewState="false" , then how is the data entered after the postback when we use a control, for example, a text field, a radio button, etc., please discuss the internal problem .

Thanks.

here is my aspx code

 <%@ Page Language="C#" AutoEventWireup="true" EnableViewState="false" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2" %> 

  <asp:TextBox ID="TextBox1" runat="server" style="position: relative; top: 0px; left: 0px;"></asp:TextBox> <asp:TextBox ID="TextBox2" runat="server" style="position: absolute; top: 66px; left: 11px; z-index: 1;"></asp:TextBox> <asp:RadioButton ID="RadioButton1" runat="server" style="position: relative" /> <asp:CheckBox ID="CheckBox1" runat="server" style="position: relative" /> &nbsp;<asp:Button ID="Button1" runat="server" Text="Button" /> </div> </form> 

+1
viewstate
source share
2 answers

Input data is saved because the browser sends input data to the server with each postback. For example, the text field on the page has its own text sent to the server each time there is a postback. Therefore, the text property does not need to be stored in a view state for storage via postback.

For more information on view state, see this article: Understanding ASP.NET View State .

+4
source share

Take a look at Server Controls retain their state when EnableViewState is set to False

Example : programmatically set the backcolor setting. In postback, if view mode is disabled, the background color of the Textbox control will be lost. However, the text value of the control is retained.

Note. If the backcolor was installed directly in the markup, and not in the code behind, it would be saved.

 <form id="form1" runat="server"> <asp:TextBox ID="Textbox1" runat="server" EnableViewState="false"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" EnableViewState="false" /> </form> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { this.Textbox1.BackColor = Color.Yellow; } } 

Also see

0
source share

All Articles