nitinvertigo
nitinvertigo

Reputation: 1180

Pass parameters to jquery function on onclick

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?

Upvotes: 0

Views: 1235

Answers (1)

Pragnesh Khalas
Pragnesh Khalas

Reputation: 2898

You can pass the value like:

onclick='<%# "timepass(" + Eval("LoginName") + ");" %>'

<script type="text/javascript">
        function timepass(pass) {
           alert(pass);
}

Upvotes: 1

Related Questions