Updating TextBox on the client with Javascript and reading the value from the Server
<p>I used Javascript on the client to update an ASP Textbox control which was rendered as an HTML textbox.</p>

<p>When I tried to access the value in the textbox control on the server, I wasn't too surprised that the Textbox's updated value was not accessible through the normal Text property of the TextBox server control, since the state of that value, I assume was probably saved off in the ViewState and the Server was unaware that Client script had changed it.</p>

<p>Is the best way to get the updated value using something like:</p>

<p>Request.Form(TextBox.UniqueID)?</p>

<p>I suspect that because the textbox is populated within a row of a GridView control and the row was added at run time when doing a DataBind, that I may be getting different results than if the TextBox were drawn on the control at Design time. </p>

<p>I confirmed that the value placed into the textbox by the client is accessible via this:</p>

<pre><code>Request.Form( CType(Row.Cells.Item(4).FindControl("txtTotal"), TextBox).UniqueID)
</code></pre>

<p>but not accessible via this:</p>

<pre><code>CType(Row.Cells.Item(4).FindControl("txtTotal"), TextBox).Text
</code></pre>

<p>the latter returning an empty string.</p>

<p>I think these two lines tell the whole story.</p>

<p>It seems ugly to have two properties to get the value of the textbox and even uglier when you consider that they return different results.</p>

<p>Is there a better way or is this just client side development in all its glory?</p>

<p>I'm always surprised when people say that web development now days is as easy as client (eg winform) apps now that ASP.NET keeps track of state. To me, web development is always more complex and costly, but I admittedly am not that skilled in web dev.</p>
