Click here to Skip to main content
15,885,720 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi guys,

i have asp.net web application,

where i have javascript function with parameters
and i have a button in repeater. i want to call this javascript function on button and want to pass the parameters also.
how can i pass this '<%# Eval("RegNo") %>' as parameter

javascript
<script type="text/javascript">
    function UpdateDiff(RegNo) {
        $('.Display').attr('href', 'UpdateDifferences.aspx?RegNo=' + RegNo.toString() + '');
    }
</script>


I want to call this on button click from repeater.

please guys help me, how can i do this.

Thanks
Posted

1 solution

add onclientclick [^]
JavaScript
OnClientClick='<%# String.Format("javascript:return UpdateDiff({0})", Eval("RegNo")) %>'

multiple parameters :
JavaScript
OnClientClick='<%# String.Format("javascript:return UpdateDiff({0}, {1})", Eval("RegNo"), Eval("Name")) %>'
 
Share this answer
 
v2
Comments
abdul subhan mohammed 19-Nov-14 11:53am    
what if i want to pass more than one parameter to javascript function: updatediff(p1, p2)
DamithSL 19-Nov-14 12:01pm    
check my updated answer
abdul subhan mohammed 19-Nov-14 13:24pm    
Thank you v.much, @DamithSL
DamithSL 19-Nov-14 13:24pm    
you are welcome!

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