Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery to get value from Server Tag data bind
    primarykey
    data
    text
    <p>Hi I am using jquery to get the values from my server tag in ASP.NET. All that javascript are on the same page. I have tried this</p> <pre><code> &lt;asp:TextBox ID="LastNameTextBox" runat="server" Text='&lt;%# Bind("LastName") %&gt;' /&gt; </code></pre> <p>and the jquery</p> <pre><code>$("#&lt;\%=LastNameTextBox.ClientID%&gt;").val() </code></pre> <p>notice I have to escape the % so that the whole quote will be a string. I don't know why this is like that; the examples I saw did not need to escape the %. I also found in another post that I should use the class so I did this</p> <pre><code>&lt;asp:Label ID="LastNameLabel" runat="server" Class = LastNameClass" Text='&lt;%# Bind("LastName") %&gt;' /&gt; </code></pre> <p>and the jquery is this </p> <pre><code>$(".LastNameClass").val() </code></pre> <p>This got me further but it returned me the function not the value. I change val() to text() nothing. I am thinking that it because I am binding the data and that the tags are in a template that I am using in a form? Any insight or advice on what I should try next? </p> <p><strong>Edit: Here is the Code</strong></p> <pre><code>&lt;form id="form1" runat="server"&gt; &lt;asp:ScriptManager ID="ScriptManager1" runat="server" /&gt; &lt;asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="SchoolDataContext" EnableUpdate="True" EntityTypeName="" TableName="People"&gt; &lt;/asp:LinqDataSource&gt; &lt;asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="PersonID" DataSourceID="LinqDataSource1"&gt; &lt;EditItemTemplate&gt; PersonID: &lt;asp:Label ID="PersonIDLabel1" runat="server" class="PersonalIDLablel1" Text='&lt;%# Eval("PersonID") %&gt;' /&gt; &lt;br /&gt; LastName: &lt;asp:TextBox ID="LastNameTextBox" runat="server" class="LastNameClass1" onBlur="textBlur();" Text='&lt;%# Bind("LastName") %&gt;' /&gt; &lt;br /&gt; FirstName: &lt;asp:TextBox ID="FirstNameTextBox" runat="server" Text='&lt;%# Bind("FirstName") %&gt;' /&gt; &lt;br /&gt; HireDate: &lt;asp:TextBox ID="HireDateTextBox" runat="server" Text='&lt;%# Bind("HireDate") %&gt;' /&gt; &lt;br /&gt; EnrollmentDate: &lt;asp:TextBox ID="EnrollmentDateTextBox" runat="server" Text='&lt;%# Bind("EnrollmentDate") %&gt;' /&gt; &lt;br /&gt; &lt;asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" /&gt; &amp;nbsp;&lt;asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /&gt; &lt;/EditItemTemplate&gt; &lt;ItemTemplate&gt; PersonID: &lt;asp:Label ID="PersonIDLabel" runat="server" class="PersonalIDLablel" Text='&lt;%# Eval("PersonID") %&gt;' /&gt; &lt;br /&gt; LastName: &lt;asp:Label ID="LastNameLabel" runat="server" class="LastNameClass" Text='&lt;%# Bind("LastName") %&gt;' /&gt; &lt;br /&gt; FirstName: &lt;asp:Label ID="FirstNameLabel" runat="server" Text='&lt;%# Bind("FirstName") %&gt;' /&gt; &lt;br /&gt; HireDate: &lt;asp:Label ID="HireDateLabel" runat="server" Text='&lt;%# Bind("HireDate") %&gt;' /&gt; &lt;br /&gt; EnrollmentDate: &lt;asp:Label ID="EnrollmentDateLabel" runat="server" Text='&lt;%# Bind("EnrollmentDate") %&gt;' /&gt; &lt;hr/&gt; &lt;asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit" /&gt; &lt;/ItemTemplate&gt; &lt;/asp:FormView&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload