2

How register (call) jQuery function from asp.net usercontrol from codebehind file?

1
  • Are you using an UpdatePanel or is this on page load? Commented Jun 14, 2010 at 20:19

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@Bendar - Welcome! And welcome to SO! Be sure to accept answers, mingle with the natives and enjoy your stay :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.