Reputation: 3968
I have an asp textbox, declared like this in the code:
<asp:TextBox runat="server" ID="txtEmail" autocomplete="email" />
Which looks like this on screen when I have added content to the input:
and looks like this in Chrome developer tools:
even when I have added content to it (eg content does not show up in developer tools).
Next, I have this textbox:
<asp:Textbox id="AddressInformation" Text="" runat="server"/>
and I add content to it using JQuery, by doing the following:
$('#<%= AddressInformation.ClientID %>').text(AddressString);
and then it is emplty on screen - like this:
and looks like this in developer tools (eg content does show up in developer tools):
The problem is, that when I postback, I want to be able to to read the value from the AddressInformation textbox in the C# code, but this does not work.
I am trying to do so using:
AddressInformation.Text
but this does not work as it normally would - it just returns an empty string.
I have looked for other options on AddressInformation, such as inner text, but cant find one.
I suspect the issue is to do with the fact that I am using .text()
to populate this, and that is why the address and email look different in developer tools. I note that the email value does not show in developer tools even when the input has a value, but the address value does show up.
I am sure it is possible to do what I am trying, as it is essentially the same thing as .net does on the postback - I just cannot work out how to do it - any ideas?
Upvotes: 0
Views: 138
Reputation: 14992
In the following line:
$('#<%= AddressInformation.ClientID %>').text(AddressString);
Instead of populating using .text()
, populate it with .val()
Upvotes: 1