How register (call) jQuery function from asp.net usercontrol from codebehind file?
Asked
Active
Viewed 2,455 times
2
-
Are you using an UpdatePanel or is this on page load? – Nick Craver Jun 14 '10 at 20:19
1 Answers
4
You can use ClientScriptManager.RegisterStartupScript(), for example:
var script = "$(function() { $('#message').fadeIn(); });";
Page.ClientScript.RegisterStartupScript(GetType(), "keyHere", script, true);
This gets rendered to the page as:
<script type="text/javascript">
$(function() { $('#message').fadeIn(); });
</script>
The script is just any JavaScript, nothing special about jQuery, just put in there whatever you would manually put in the page, since that's how it ends up.
Nick Craver
- 623,446
- 136
- 1,297
- 1,155
-
1@Bendar - Welcome! And welcome to SO! Be sure to accept answers, mingle with the natives and enjoy your stay :) – Nick Craver Jun 14 '10 at 21:45