Getting value from a textbox control that was filled with a value from javascript

 I have a textbox control (seen below txtMileageDollars1) that gets filled with javascript based on the number of miles a user types into another textbox (txtMileageMiles1) control.  When I post back with the submit button, the value is blank.  I've tried setting EnableViewState to false, but still cannot get a value on postback.  Does anyone have a solution?


asp:TextBox ID="txtMileageMiles1" runat="server" Width="50px"></asp:TextBox>


Total (txtMileageMiles1 * rate with javascript)
asp:TextBox ID="txtMileageDollars1" runat="server" EnableViewState="false" Width="50px" ReadOnly="true"></asp:TextBox>

9/7/2008 3:30:06 PM 91979 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 27


It seems a confusion in your question, whether you want to persist value in the text  box or not? I you want to then you shuld enable control's view state to true. otherwise you can set it to false.


Naveed Akhtar

Microsoft Certified Professional Developer
Please remember to click “Mark as Answer”, if it is solution to your Problem
9/7/2008 3:48:53 PM

The value will change when the user is filling out the form.  When the form is posted back, the calculated field (changing from javascript) does not have a value.  Since the value can change a number of times when a user is filling it out, the value cannot be persisted.  Either way, I've tried EnableViewState="True" and EnableViewState="False" and both do not procur a value on postback.

9/7/2008 4:28:31 PM

I was able to work it out to use html controls <input type="text" runat="server" .... instead of textbox controls.

9/7/2008 5:05:12 PM

Similar Artilces:

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...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

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...

How to pass in value to javascript from database or let javascript to get value from database?
I am trying to use google map api to do some web based application.On the map, the javascript needs latitude and longitude from database to draw a marker on page load, I am wondering how can I get the data from database to do that? The map part will be like a image, won't change.Do I need Ajax?Thank you.  hanxiao:I am trying to use google map api to do some web based application.On the map, the javascript needs latitude and longitude from database to draw a marker on page load, I am wondering how can I get the data from database to do that? The map part will be like a image, won&...

Get values of textbox with values seperated by comma
I am trying to get a better way of entering the same data over and over, my first thought was multiple textboxews but in todays world there has to be a better way, so I thoguth i couold just add one textbox to page and they can enter all batch numbers in that textbox seperated by a comma and then I could pull them and insert them individually into the sql database.  Is this a good method or should I put a link button that they refresh the page and enter  a signle one everytime.  here is the code I have to enter it all in one text box but I get all kinds of error on it.  ...

How do I get get values of controls inside datalist?
How do I get values of controls inside datalist?   For example, if I have a label inside header template or item template or footer template? Is there anyway to change property of label or any other controls inside those template as well? I would really appreciate if anybody can just post a sample code or a helpful link about datalist? Would really like to know more about the events fired for datalist, itembound, itemcreating etc?   hey there,I used this page to work out how to use datalists

javascript and getting values from controls...
hi. i have a problem thats driving me nuts. i get some data from a dataset. then i send the data to a label, writing it out from codebehind to a number of radio buttons. then when trying to get the data and pass it to a hidden textbox nothing happends, i get an error saying more or less that my textbox is empty. now ive been at this sucker for days and i just dont know. the code has worked before, but in a page. now im trying to use it in a usercontrol and get this error. here is some code: the loop in with i write the data out form the dataset to radiobuttons: (tempset is the d...

Getting textbox value through javascript
I made a function in js that supposed to get a textbox value: function check(inputField) { var txt=inputField.text; alert(txt); } c# code: TextBox tbox = new TextBox(); LinkButton lbtn = new LinkButton(); lbtn.Attributes.Add("onclick", "check('" + tbox + "')"); in the alert it writes "unidentified"   any ideas IdanSheffer: TextBox tbox = new TextBox(); LinkButton lbtn = new LinkButton(); lbtn.Attributes.Add("onclick", "check('" + tbox + "')"); Did you add the referenc...

how to get textbox value in javascript??
i have textbox in datagrid n want to acess tht value in javascript.........hw iwll do tht? ItemTemplate> <asp:TextBox ID="txtbxEndDate" runat="server" Style="width: 70px"></asp:TextBox> <asp:ImageButton ID="imgEndDt" runat="server" TabIndex="9" Height="21px" ImageUrl="../Images/calecder.jpg" AlternateText="SelectDate" OnClientClick="return false;" /> <ajaxToolkit:CalendarExtender ID="clndrEndDt" runat="server" Format="MM/dd/yyyy" Targ...

How to get the Value from the Textbox ?Textbox is created by using add control function.
  Dim textWG As New HtmlInputText textWG.text="Wage Rate" textWG.ID = "txtWG" me.control.add(textWG) i write this code at form load.moreover this form have one save button to save the value from the "txtWG" to database this textbox will be appear when form finish load.but after click save button the value cant be save into database. tat textbox become empty when user click the save button. how can i get the value from that textbox ? Please advice me.Thank you You are using a HTML control and by default, HTML controls dont have a mechanism to pres...

Getting values from Javascript controls to dotnet
I am creating few controls like textboxes dynamically using javascript , now how do I get values of those controls once I submit the page in dotnet. You have to use the Request.Form collection.  Note that this collection only stores the values of the textboxes.  Example: Dim strName as String = Request.Form("txtName") Hope this helps!  Please mark the helpful post(s) as Answer.Josh Stodola ← Come check out my blog! In your page_load you can have something like this: Dim test As New TextBox test.ID = "txtTest" test.Text = "Test" M...

get value from javascript to web control
In my page I have label control <asp:label id="Label1" runat="server" /> when page load I set that label value using javascript function setvalue() { document.getElementById("Label1").innerHTML = "hello" } <body onLoad="setvalue();"> and i also have a button. When I click that button, it read the label value Private Sub BtnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSubmit.Click Dim a as string = Label1.Text end sub but the problem is var...

how to get label control value in javascript.
 Hi I need to get the label Text when the User clicks the browser close button.function fnPassValues() {     if((window.event.clientX < 0) || (window.event.clientY < 0))     {        var temp = document.getElementById("<%=lblValue.ClientID%>").innerText;        alert(temp);     } }If i set the value like this, its working correctly. <asp:Label ID="lblValue" Text="3" Height="20px" runat="server" CssClass=&quo...

How to get TextBox value that was set by JavaScript
Hi, I used a JavaScript to set a TextBox value.  This works ok, it displays the correct value when the page is rendered.  But when I try to access the TextBox value using the server side code, it does not read the new value.  (I'm assuming it is because the JavaScript code is not actually adding the Text property to the rendered HTML) Here is my test code, does anyone have any ideas? protected override void OnLoad(EventArgs e) { base.OnLoad(e); TextBox tb = new TextBox(); tb.ID = "TestTextBox"; tb.Visible = true; tb.Text = "...

Web resources about - Getting value from a textbox control that was filled with a value from javascript -

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

Lightbox (JavaScript) - Wikipedia, the free encyclopedia
On a Lightbox-enabled page, a user can click an image to have it magnified in a Lightbox window, which resizes itself according to the size of ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
about dmoz - help Top : Computers : Programming : Languages : JavaScript : Tools : Obfuscators Tools for obfuscation/compression JavaScript code. ...

Facebook File-Transfer App Pipe Relaunches, Now Works Via JavaScript, WebRTC
... allowed Facebook users to send and receive files up to 1 gigabit in size. A new version of Pipe debuted Monday, and the app now works via JavaScript ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

JavaScript SDK - Facebook-Entwickler
Overview The JavaScript SDK provides a rich set of client-side functionality for accessing Facebook...

Senior Front-End Developer (Javascript and AJAX)
Company: Sometrics Category: Software Development Location: Los Angeles, CA How to Apply: Description: We are looking for ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken .… ...

Resources last updated: 12/9/2015 2:36:50 AM