Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to pass Datagrid textbox ID to javascript function


Following is the Textbox Control from Datagrid

C#
<asp:TextBox ID="txtQuote" runat="server" CssClass="textbox" MaxLength="10" style="text-align:center" onmouseover='changeText("<%=txtQuote.ClientID%>")' Text='<%# DataBinder.Eval(Container.DataItem,"Quote_Value") %>' Width="100%">


JavaScript function

XML
<script type="text/javascript">
function changeText(text) {
//var display = document.getElementById(text);
alert(text);
//display.innerHTML = "";
//display.innerHTML = text;
}
function changeback(text) {
var display = document.getElementById('text-display');
display.innerHTML = "";
display.innerHTML = text;
}
</script>


Alert always shows this string value: "<%=txtQuote.ClientID%>", it is not showing the textbox ID
Posted
Updated 7-Jan-15 20:41pm
v2

1 solution

Do like below...
HTML
onmouseover='changeText(this.id)'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900