Forums - C# Corner

Forum guidelines
Ye Htut

Ye Htut

  • 1.5k
  • 40
  • 11.8k

Fire textchanged event in javascript asp.net c#

Sep 27 2016 10:53 PM
in my application, I used asp.net Repeater with table to populate item from database and DropDownExtender of Ajax. When user clicks on textbox, data with html data've been shown.Now I want to fire textchanged event of textbox when data row is selected. I bind data to repeater in page_load.
Thanks All

What I have tried:

in javascript
function SetValue(value) {
var DropdownList = document.getElementById("<%=ddlItemID.ClientID %>");
// txtFriend.value = value;
alert(value);
}
at repeater, I tried like this
<asp:Repeater ID="rptr" runat="server">
<HeaderTemplate>
<table style="border: 1px solid black;" >
<tr style="border: 1px solid black;">
<th style="border: 1px solid black;">
ID
</th>
<th style="border: 1px solid black;">
Unit
</th>
<th style="border: 1px solid black;">
Price
</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr onclick="SetValue('<%#Eval("ID")%>')" style="cursor: hand" onmouseover="style.backgroundColor='#bfb9b9'"
onmouseout="style.backgroundColor=''" style="border: 1px solid black;">
<td style="border: 1px solid black;">
<%#Eval("ID")%>
</td>
<td style="border: 1px solid black;">
<asp:Label ID="lbFirstName" Text='<%#Eval("Unit")%>' runat="server" />
</td>
<td style="border: 1px solid black;">
<asp:Label ID="lblLastName" Text='<%#Eval("Price")%>' runat="server" />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr onclick="SetValue('<%#Eval("ID")%>')" style="cursor: hand" onmouseover="style.backgroundColor='#fff4f4'"
onmouseout="style.backgroundColor=''" style="border: 1px solid black;">
<td style="border: 1px solid black;">
<%#Eval("ID")%>
</td>
<td style="border: 1px solid black;">
<asp:Label ID="lbFirstName1" Text='<%#Eval("Unit")%>' runat="server" />
</td>
<td style="border: 1px solid black;">
<asp:Label ID="lblLastName1" Text='<%#Eval("Price")%>' runat="server" />
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

Answers (3)