i have a javascript function say 'onclientclicking'.
<script type="text/javascript">
function OnClientClicking(button, args) {
window.location = button.get_navigateUrl();
args.set_cancel(true);
}
</script>
I want to execute this function from code behind. What i am trying to do is based on certain conditions, i need to set the event to telerik button
rad_btn_text.Attributes["OnClientClicking"] = javascript function;
how can it be possible?
regards,
Sivajith S
i have a javascript function say 'onclientclicking'.
<script type="text/javascript">
function OnClientClicking(button, args) {
window.location = button.get_navigateUrl();
args.set_cancel(true);
}
</script>
I want to execute this function from code behind. What i am trying to do is based on certain conditions, i need to set the event to telerik button
rad_btn_text.Attributes["OnClientClicking"] = javascript function;
how can it be possible?
regards,
Sivajith S
Share Improve this question edited Jun 23, 2014 at 8:11 Giulio Caccin 3,0496 gold badges37 silver badges59 bronze badges asked Oct 10, 2013 at 12:18 SivajithSivajith 1,2115 gold badges20 silver badges39 bronze badges 3- paste ur html(design) code.. – Somnath Kharat Commented Oct 10, 2013 at 12:24
- 3 You can't call a javascript function from code behind. You can just associate method (javascript-function) with control. Or if you want to call it it should be a part of your response stream. And when browser will start rendering the form it will execute that function once it reach there. – शेखर Commented Oct 10, 2013 at 12:24
- Could you plese mark as answered or provide feedback? – Giulio Caccin Commented Nov 30, 2014 at 11:58
5 Answers
Reset to default 1please try this:
rad_btn_text.OnClientClicking = "OnClientClicking";
It's working on my machine™
You can't "call" client side javascript from the server. That said, you can wire up client side events and emit client side code.
I don't use telrik controls but the asp property is onclientclick. Not sure if that is the same on a telerik control and the client side event is onclick.
To call the javascript function from server side:
ScriptManager.RegisterStartupScript(this, typeof(Page), "OnClientClicking", "OnClientClicking();", True);
References
- help on MSDN
- OnClientclicking in telerik
rad_btn_text.Attributes.Add("onclick", "OnClientClicking()")
Hopefully this works for you
try this. when user click on button the function of "OnClientClicking" will be executed :
rad_btn_text.Attributes["onclick"] = "OnClientClicking()";