I am trying to pass a parameter to my jquery function through the onclick event of a textbox. This is the code:
HTML Code:
<asp:TextBox ID="txtLoginName" OnClick='timepass(<%# Eval("userid")%>);' Text='<%# Eval("LoginName")%>'
runat="server"></asp:TextBox>
and my jquery function:
<script type="text/javascript">
function timepass(pass) {
alert(pass);
}
but nothing happens. When I pass like this on onclick event OnClick="timepass(123)"
it works fine. What am I doing wrong?
You can pass the value like:
onclick='<%# "timepass(" + Eval("LoginName") + ");" %>'
<script type="text/javascript">
function timepass(pass) {
alert(pass);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.