Why the value of textbox get preserved after post back even if viewstate property is false?

Hi All,

        I have simple aspx page  whch contains one textbox and one button.Enable viewstate property of textbox is false .Both textbox and buttons are server controls.When I view the page in browser and add some string in textbox and after clicking on button it get post back and text box shows me a same value even if enable view state property of that text box is false.

What is the reason behind it?

 Idealy it should not preserve the value as enable view state is false.


Suyog
I am just using my free time,but if it helps you then my mark my post as answer
2
suyog
5/7/2008 1:11:17 PM
asp.net.state-management 8807 articles. 0 followers. Follow

5 Replies
19888 Views

Similar Articles

[PageSpeed] 57

I think I have the same problem and I can't figure out, why after postback im still showing my value.

I have a textbox that when I enter 0 it deletes that record.

Now instead of showing me an empty textbox, after deleting the record, it shows me a 0. If I refresh or do a postback then it shows me an empty textbox. Why is this? I tho by using EnableViewState="false" this value should not be preserve...?

0
diazmayo
5/7/2008 1:40:31 PM

Hi,

That's because in case of textboxes, the values get submitted to the server on every postback and are available in teh Request.forms[] collection. Hence despite of the viewstate being disabled for textboxes, the value is fetched from the Request.forms collection and displayed.

HTH,
Suprotim Agarwal


ASP.NET Grid With Excel Capabilities | 27 GridView Tips & Tricks | Hosting your site? | SQL Server Tips
3
Suprotim
5/7/2008 1:46:12 PM

How can I stop the textbox from retaining that value? Is misleading the right information

3
diazmayo
5/7/2008 2:02:42 PM

 You can't stop it from having the value it should have, because that is how post requests in web forms are working. If you need to know the old value (default value, prior you typed something in textbox) you can obtain it in OnInit and save it there in some private variable and then restore the value of textbox back to the old value in PageLoad.


Blog: http://blogs.mscommunity.net/blogs/borissevo/

Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post fixed your problem.
2
bsevo
5/7/2008 2:12:52 PM

diazmayo:
How can I stop the textbox from retaining that value? Is misleading the right information

simply , set its Text proeprty to an empty string like this :

 textBox1.Text=""

 

Actually , we discuss this before , have a look

http://forums.asp.net/t/1234531.aspx

http://forums.asp.net/p/1173606/1970749.aspx

 

Best Regards,
 


Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

-5
anas
5/7/2008 8:06:35 PM
Reply:

Similar Artilces:

How to get textbox value when textbox properties is readonly or enabled false
Hi ,I have one problem, If u have idea please solve  itTo dispaly canlendercontrol iam using ajax canlender control, after selecting dateof birth into textboxIn textbox keeping textbox properites as readonly or enabled equal false,  getting that textbox value into lable,  ThanksRamesh  Just get the Textbox.Text value?Don't forget to click "Mark as Answer" on the post that helped you. If I understand you correctly, you have a textbox that is disabled/readonly. You use some code to change the value in the textbox, and you want that value to be returne...

Preserve View State value at post back
Hi All,    I am creating a custom server control.That control contains a check box list. For the first time I am getting value for that check box list, at run time through Get/Set property. In Property I am using View state for setting value. While page is post back, the view state is getting null. How can I preserve the value of view state. Sample code is as follows,  private CheckBoxList _chkList;protected override void CreateChildControls() {string strItems; string[] StrArrItem = null;char cSplitChar = ','; int intLegth = 0;_chkList = new CheckBoxList(...

trying to get the value of a textbox.text before a post back
ASP.NET 2.0. VB.Net  I am trying to get the value of this textbox before postback<asp:TextBox ID="Notes" runat="server" TextMode="MultiLine" Rows="6" Columns="90"></asp:TextBox>Once I get the value I would like to update a DataSet before postback 'Update Email Message Dim UpdateEmail3MessageAdapter As New Email_Temp3TableAdapters.Email_Temp3TableAdapter Dim UpdateEmail3Message As Email_Temp3.Email_Temp3DataTable = UpdateEmail3MessageAdapter.GetDataEmail_Temp3 For Each UpdateEmail3MessageRow A...

User Control Property Persistence
I have a user control that's rendered in a data bound List View, for example:<asp:ListView ID="ListBuildings" DataSourceId="ListDataSource" runat="server"><ItemTemplate>    <custom:Rater ID="Rater" BuildingId='<%# Eval("BuildingId")%>' runat="server" /></ItemTemplate></asp:ListView> I set a custom property on my user control called BuildingId, but on post backs I'm not finding the BuildingId property set to what I set it to in the through the list view's databind...

problem with get value from textbox after get it value in load page
hi every one  i have problem with my web site when i get textbox value in load page   and Changed textbox the page do not take last value .   it take value in load page   this is code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)   TextBox1.Text = "aa" End SubProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) MsgBox(TextBox1.Text) End Sub   when i press button message write "aa" while i changed the textbox   please if enyone knowen help me &nbs...

How to get value from dynamic control on Post-back
Hi All, This is my first post. The problem is about dynamic control. 1. In Page Load, I auto generated a datagrid.  Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load         Dim lmws As New LIMSWSV10.LIMSService         Dim ds As New DataSet         If Not IsPostBack Then             ds = lmws.GetResultValueForShippingJob(Request.QueryString("ShippingJobID")) ...

Why I get old values from a textbox even if they are changed?
 Hi to all,i'm developing a dnn component that updates some data stored on the db. To do so, i've made a simple select query to fetch the old values, then the onload event popolates a form using a VB codebehind.To update the user changed data, i've insert a update_button, that the user must click in order to run the update.in the codebehind, i've made a function raised on the  update_button.click event but when the update function collects the changed data, it still collects the old values, even if they are changed... WHY?  could someone help me?please :) Thanks to all,/D   Have you put an "If Not Page.IsPostBack Then" statement around your onload code? Failure to do this would cause you to pick up the same values each time. Hope this helps Please mark posts as the answer if I was helpful. Thanks!Visit my blog  Yep! Was That... i forgot that because... i'm novel in .net developing... Now works fine! really really thanks!    ...

ViewState Remains as it is even if I explicitly false it in my textbox.
Hi All,I have a simple form in C# (ASP.NET 2.0) web application and on that I have taken one textbox and a button.<asp:TextBox ID="txttest" runat="server" EnableViewState="false"></asp:TextBox><asp:Button ID="btntest" runat="server" Text="Test" />Now execute this page and write anything in text box say "Hello" and click on a button.Here I have written EnableViewState="False" then also when I click on button, it refreshes the page and re-filling "Hello" in that textbox.If we see practic...

Getting control value inside the grid at the post back
Hi,       I used the DropdownList control inside the gridview and i want to retrive the value of dropdown in gridview at the page postback. Is it possible to get the value using "Request.Form"? or is any other method to reteive the value?. Looking for help   Thanks  Dropdownlist ddl = (Dropdownlist)gridview1.rows[gridviewrowno].FindControl("dropdownlistid");string selvalue  = ddl.SelectedValue; in above you have to change  gridviewrowno to the rowno you wants to retrieve.dropdownlistid to the id of the dropdownlist in...

where is the value saved of the form controls(such as textbox) in post backs?
hello! I have some puzzle in view state.I have just read an article in Msdn about view state.http://msdn2.microsoft.com/en-us/library/ms972976.aspx,It says, there are many stages in the life cycle of the page,and the Stage 2 is Load View State,the Stage 3  is Load Postback Data.In Stage 2 ,it says : During this stage, the view state data that had been saved from the previous page visit is loaded and recursively populated into the control hierarchy of the Page. And the Stage 3 is Load Postback data of the form controls, My first question is: what is the difference of the view state data(Stag 2)and the value of the control(Postback data in Stag 3). And the article of Msdn also says :It is a common misconception among developers that view state is somehow responsible for having TextBoxes, CheckBoxes, DropDownLists, and other Web controls remember their values across postback. This is not the case, as the values are identified via posted back form field values, and assigned in the LoadPostData() method for those controls that implement IPostBackDataHandler. My second question is :now that the view state is not responsible for the values of the form controls,where is the value save? thank you. The values from form inputs such as textboxes etc are captured in the Request.Form collection, or Request.Querystring if you are using GET as opposed to POST. In classic ASP, PHP etc, you have to manually retrieve values from the inputs on postback (form submission) and re...

How to get table control values on post back event?
Hi, I am using table control in asp.net, there are 3 columns in the table, values of first two columns are added manually at design time and third column has text box where user needs to add values. On button click event i need to save table (cell) values of column2,column3, but some how on post back event values are disappearing in the table. There is no limit on rows, it can be one or 20 depends on user selection. Is there any way to save table values on post back event or can i disable post back event for button so that table values will not be disappeared? Thanks ...

PayPal Integration with .net (to get values back from PayPal)
 We want to integrate our ASP.Net webapplicaiton to PayPal. Currently we are in teh process of developing the application so we are using PayPal sandbox. When user clicks on checkout button we pass the control to paypal sandbox, where the items along with their price is displayed. Now suppose user pays for the items, now control should come back to the main application along with the information whether payment was successful or not and also the transaction id (which we need to put in our database). Please let me know how we can do this. Also, do we need a public ip so that sandbox can send the control back to the main application. Currently the application is under development so not deplyed on any servers with external ips. Paypal's SDK kit for ASP.Net may be a good start. There are instructions, documentation and sample code available on that site. iHaathiThis post is given AS-IS. No Warranties. Check Rick's article http://www.west-wind.com/presentations/PayPalIntegration/PayPalIntegration.asp ThanksMark post(s) as "Answer" that helped youElectronic ScrewWebsite||Blog||Dub@i.net well go to paypal web site and login with paypal's account username , you will see there two urls one if successful and other for unsuccessful. so you will be redirected to that page. you can find how to get transaction id in pdf file available there. if still you need code of getting id you can post i will write code here.http://www.munishbhatia.com Hel...

Get values set by javascript to .net enabled textbox
I have a bit of javasript that writes a value to a text box.  The text box is read only. Textbox code:<input type="text" id="txtColor1" runat="server" readonly="readonly" size="6" /> Snippet from javascript functioncolorBox = document.getElementById('<%= txtColor1.ClientID %>');colorBox.value = colorCode;  Code behind:string color1 = txtColor1.Value Whenever I attempt to get the value out of the text box after it has been changed by the javascript, it always reverts back to the old data and not the new. Anyo...

Trouble getting selected value from DropDownList when posted back
I have a DropDownList inside a Repeater with AutoPostBack=True. I need to get the selectedvalue of the DropDownList so that I can populate another DropDownList based on its value. I was trying to do this in the Page_Load method but the value is coming back as null. Here's what I was trying. What am I doing wrong? Thanks <asp:DropDownList ID="OfficeDDL" runat="server" AutoPostBack="true" /><br />  if (Page.IsPostBack) { DropDownList OfficeDDL = (DropDownList)EmployeeOfficeAddressRepeater.FindControl...

Getting viewstate value from readonly textbox in .NET2 (VB)
Hey guys...I have a form that asks for several dates.  I tried using asp calendar controls to set values of the date textboxes which were readonly.  I found this annoying since each time I advanced a month and/or selected any date, it posted back and refreshed the page. So, instead, I resorted to an old javascript function I use a lot.  The javascript creates a pop up (html) window and sets the value of the textbox when the user picks a date.  I had done this many times in ASP.NET1.  However, since upgrading to .NET2, I noticed I was getting errors and the data I was...

get html textbox value in C#.net(code behind)
  i am new to ASP.net. Can anybody say how to get Input textbox value in C#.net. b4 sending answer Thankx  string value = Resquest.Form["textboxname"].ToString(); Hi,There are two ways to access it. 1) Make it runat="server" and access it in code behind like textbox1.value2) Another way is by using     Request.Form["textbox1"].ToString(); I hope this will be helpful to you.Thanks, Alpesh DhaneshaPlease don't forget to "Mask as Answer" if it helped. just add runat =server to html  ...

VB.net add textbox values together to get total
Hi Guys Im using visual studio 2005 vb.net. sql express, im a newbie and im basically trying to create a customer calculator. Ive got this code, basically i want to add the integer values of each of my text boxes together and then display them in a textbox called textbox1.  I think i have the code write to do the calculation but im stuck on how to get it to display the total in the textbox once ive hit the calculate button, ive tried several ways, the page posts back, i get no errors but nothing in textbox1 toocan you take a look and help me out please. Thanks and Kind Regards &...

How to change the value of textbox without posting page back to the server
Hello everyone, I have a simple form with 3 textboxes namely txtNumber1, txtNumber2, txtTotal. The txtTotal will display the sum of txtNumber1 and txtNumber2. I'd like when the user enter a number either in txtNumber1 or txtNumber2 the txtTotal will automatically update its value without posting page back to the server. Do I need to utilize Ajax to accomplish it? Thanks for reading.   There are couple of options you can use: 1] Use Java Script to Populate your txtTotal on change of text in txtNumber1  / txtNumber2 2] You can use AJAX, by putting your controls in UpdatePanel. Have a button Calculate (outside Update Panel), which will calculate and populate txtTotal from you. Ho[pe this helps. Thanks, -Nirmal I think i will use the first approach. But could you please tell me more detail?I'm not sure how to use JavaScript in ASP.NET pages. Thank you for your reply  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Sum Example</title> <script type="text/javascript"> function Sum() { var txtNumber1 = document.getElementById('txtNumber1'); var txtNumber2 = document.getElementById('txtNumber2'); var txtTotal = document.getElementById('txtTotal'); if ...

How to retain and get the selected value of the drop down upon post back
Hi I have a form view. Inside the formview I have a drop down. I did not bind the drop down with the ODS. Instead I do it manually on the code behind. If the user selects a value I display a textbox beside the drop down and allow the user to enter the value. Upon onblur event of the textbox I do a postback and in the page load i check whethere the page has been posted. If so I add this value to the datatable and once again bind it to the combo box and set the selected value to the text box value.    If the user clicks the save button and when I look for the selected value it says Nothing. What could be the problem. Please help me in this regard. Thanks a lot in advance.        SelectedValue could be found on the same page. If there is a postback, it will be gone. Could you show your code?  Please post your code so we can further assist you, but it seems that the value isn't being passed.~~ Believe in Science, not religion. Science will always progress, religions will always collapse. ~~ Try to user below code: <asp:dropdownlist Id="1"  Runat="Server" SelectedValue='<% Eval("Some data")%' DataTextField="Some Data Column" Sqldatasource="Sqldatasource1" />I guess this will help you.Here Selected value attribute will help you show the selected value of the user and datatext will help you show the dropdown data.....it may or may in your datasource don...

I need a multiline textbox that preserves word wrap on post back
Hi, I need a control that can satisfy the following: 1. Must have word wrap (like a multiline textbox or textarea). Word wrap should support pasted text as well as entered text. 2. Must be able to specify maximum line length (35 characters) and maximum number of lines (4). 3. When posted back, I need access to each line of text as it looked on the clients page, so it can be stored in 4 different database fields that each have a maximum length of 35 characters. This is all in order to spare users the hassle of entering their four permitted lines of text in 4 separate ...

Value of Control created dynamically is not getting populated on post back
Hi I am creating a table at run time. If I put some value to textbox, its not getting populated after post back. If I do it on Page onInit event everything works fine.. but I cant do this as I have to make rows on button click. The code is like this Sub MakeTable() Dim ht As New Hashtable ht("1") = "1" ht("2") = "2" For i As Integer = 0 To 2 Dim tr As New TableRow For j As Integer = 0 To 1 Dim td As New TableCell Select Case (j) Case 0 : Dim dd As New DropDownList dd.ID = "name" & i dd.AutoPostBack = True dd.DataSource = ht.Keys dd.DataBind() dd.Attributes.Add("runat", "server") dd.Attributes.Add("onChange", "onComboChanged(" & i & "); ") td.Controls.Add(dd) Case 1 : Dim txt As New HtmlInputText txt.ID = "address" & i txt.Attributes.Add("runat", "server") txt.Value = Request.Form("address" & i) td.Controls.Add(tx...

How to get the data in textbox when it's property is enable=false at runtime
Hi,I m doing project in  ASP.NET 2005 using  SQL  SERVER 2005 as the database. And using SQL DATASOURCE CONTROL to get the data from sql.I want to get data of dynamic control textbox at lost focus event which is enabled=false. But, I dont know the procedure to get data at lost focus event and enables property=false. how can I get it? Please answer me as early as possible.....Thanking you in advanceprotected void cmdsubmit_Click(object sender, EventArgs e)&nbsp;&nbsp;&nbsp; { &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string str;&nbsp;&nbsp...

How to get the value of a textbox that has been added to a template field in a gridview. VB.Net
I have a gridview that shows products, description, price. I have added a Buttonfield and a TemplateField that has a Textbox with the id QuantityTextBox.What I am trying to do is get the value of the Quantity TextBox in the RowCommand event of the gridview. I can get the price but need to get the quantity also. To get the price I used ItemPrice = Server.HtmlDecode(row.Cells(5).Text) My template field is cell 6 but the above routine does'nt work. Any help would be greatly appreciated.Dan5150www.5150creations.com Hiuse this: VB:  Protected Sub GridView1_RowCommand(ByVal ...

error while post back the page if any input control(textBox) has value &#
Im working in Asp.net 2.0 and Ajax 1.0 Im getting error while post back the page if any input control(textBox) has value &# im not getting error even it has value #&  Please help.... Hi ajith P T The “&#” is a special word in HTML, it might be forbid during the postback because of the security issue.If you need this in your TextBox, you can set the ValidateRequest="false" on your <%@ Page %> tag to avoid the error. Just like the following demo:  <%@ Page Language="C#" ValidateRequest="false" %> <!DOCTY...

Web resources about - Why the value of textbox get preserved after post back even if viewstate property is false? - asp.net.state-management

Preserved counties of Wales - Wikipedia, the free encyclopedia
... (Wales) Act 1994 abolished the eight ceremonial counties created by the Local Government Act 1972 . However, it created the concept of preserved ...

BIG BLUE LIVE - The Biggest Heart Ever Preserved - A Blue Whale's! - PBS - YouTube
http://www.pbs.org/big-blue-live/ Premieres on BBC One August 23, 27, 30 and on PBS August 31, September 1, 2. Jacqueline Miller from the Royal ...

'Feathered poodle from hell': incredibly well-preserved fossil of new dinosaur found
Scientists have unearthed a spectacularly preserved, nearly complete fossil in northeastern China of a feathered dinosaur with wings like those ...

Whiteley's secret garden to be preserved
IT'S onwards and upwards for Wendy Whiteley's secret garden after the NSW government granted permanency to the Sydney Harbour attraction.

Whiteley's secret garden to be preserved - PerthNow Search Search
IT'S onwards and upwards for Wendy Whiteley's secret garden after the NSW government granted permanency to the Sydney Harbour attraction.

Character of the Quay should be preserved
Does Mike Baird want to sell valuable, iconic, revenue-raising properties so he can spend money on the wharves (&quot;Baird plays ferry godfather ...

Queensland wetlands will be preserved: Seeney
A controversial plan to dump dredge spoil onshore will not damage nationally significant wetland, the deputy premier says.

Spirited: Australia's Horse Story - Preserved brain fascinates
Natalie Ison explains why a horse's brain is her favourite object from the exhibition at the National Museum of Australia.

World's oldest sperm 'preserved in bat poo'
Bat poo may have preserved the world's oldest sperm, which has been found at a fossil site in north-western Queensland, say researchers.

Edmonton jury sees preserved pelvic tissue from alleged murder victim
Canoe Crime section offers articles, videos, photos on any topics related to crime and justice.

Resources last updated: 3/24/2016 12:02:13 PM