1

i am using update panel and AutoPostback in an asp.net, but after postback my scripts are not loaded properly which are already in the page causing some of the elements that require that script to misbehave i have been told to load the scripts in pageLoad() but i am not sure how to do that. I want to load scripts such as jquery bootstrap and some other plugins just to modify the elements looks, can any one guide me?

3
  • 1
    It is best to load frameworks such as jQuery and bootstrap statically, rather than by adding them as a scriptresource. You should just add them inside a script tag in your master page. Commented Sep 12, 2013 at 13:45
  • How are you loading them now? Ordinary if you simple reference them via <script src=".... in the page itself - it doesn't matter if you use UopdatePanel or not - they should work Commented Sep 12, 2013 at 13:46
  • loading them statically does not work properly after postBack. Commented Sep 15, 2013 at 6:18

1 Answer 1

1

Actually, you can use pageOnload event to do so. Like this.

protected void Page_Load(object sender, EventArgs e)
        {           
            if (IsPostBack)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "show", "<script>document.getElementById('Your element').style.display = 'block'</script>");
            }
            else
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "show", "<script>document.getElementById('Your element').style.display = 'hidden'</script>");
            }
        }
Sign up to request clarification or add additional context in comments.

Comments

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.