Getting error message as "Script controls may not be registered before PreRender."

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rajkumarbathula
    New Member
    • Aug 2008
    • 18

    Getting error message as "Script controls may not be registered before PreRender."

    Hi

    I am creating a usercontrol in .net and using that as webpart in sharepoint site. i want to make use of ajax in my user control. and hence i added scriptmanager, updatepannel and update progress controls on to my ascx page.

    on output of the page, i am getting the error message as ......"Script controls may not be registered before PreRender."i need the solution for this error.

    i tested this ajax functionality on local website with aspx page and is working fine.

    please help me out in getting solution.

    thanks in advance.

    Raj
  • dorandoran
    New Member
    • Feb 2007
    • 145

    #2

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by rajkumarbathula
      Hi

      I am creating a usercontrol in .net and using that as webpart in sharepoint site. i want to make use of ajax in my user control. and hence i added scriptmanager, updatepannel and update progress controls on to my ascx page.

      on output of the page, i am getting the error message as ......"Script controls may not be registered before PreRender."i need the solution for this error.

      i tested this ajax functionality on local website with aspx page and is working fine.

      please help me out in getting solution.

      thanks in advance.

      Raj
      Are you manually registering script controls?
      If so, where in the page life cycle are you doing this?

      You should probably be using a ScriptManagerPr oxy instead of a ScriptManager in user controls. Usually ScriptManagers are included in the aspx page so that they are available to all controls in the page (or even a MasterPage which makes them available to all pages that use the MasterPage). You can only have one ScriptManager at a time on a page, so your UserControl might break this.

      Comment

      • rajkumarbathula
        New Member
        • Aug 2008
        • 18

        #4
        Thanks Frina.

        yes what u gueesed is correct. i am using script manager in my user control. as of now my aspx page contains only 1 user control and my masterpage is not containing any scriptmanager and hence totally there is 1 scriptmanager at the time of rendering my webpart.

        suprisingly, i am getting this error only if i use <updateprogress > tage. if i am not using this, i am not getting this error.

        so i removed it and tested, for first time the ajax functionality is working. ie., on click on a button, without postback i got my results. but from then onwards ajax is not working. i mean no functionality is happening on my page like when i click button again for another results, i am not getting that. i debugged the process and i found from second time click, the page is not getting loaded...

        dont know y??

        please give me any best solution. so tell me what i have to use instead of scriptmanager. in my ajax tool box, i didnt find the control that you said.

        plz explain clearly what i have to do.

        thanks in advance

        regards
        Raj

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Here's more information about the ScriptManagerPr oxy. You should be able to find it in the ToolBox under the Ajax Extensions section.

          Although using the ScriptManagerPr oxy is probably a good idea, it's not what's causing your problem.

          When you say:
          Originally posted by rajkumarbathula
          "on click on a button, without postback i got my results"
          You're not entirely correct. A postback does occur. It occurs asynchronously (The "A" in Ajax stands for Asynchronous).

          So this means that a postback/call to the server occurs (and since you're using an update panel the entire ASP.NET page life cycle happens) but when the response is returned to the browser only a portion of the page is updated. This lets you make multiple calls to the server from different parts of the page without having to send the whole page to the server.


          So, what I recommend is that you place a breakpoint on your Page Load event and see if a post back reaches the server the second click.....

          If it doesn't get there then we know that something's messing up client side.
          If it does get there then we know that something's messing up server side.

          Comment

          • rajkumarbathula
            New Member
            • Aug 2008
            • 18

            #6
            hi frinavale

            i am very much happy to see ur last lines ie.,

            Originally posted by Frinavale
            "So, what I recommend is that you place a breakpoint on your Page Load event and see if a post back reaches the server the second click.....

            If it doesn't get there then we know that something's messing up client side.
            If it does get there then we know that something's messing up server side. "
            i kept a breakpoint on page load and also at button click event on server side. and when i click button for first time page load is happening.

            but when i click button for second time, page load is not getting triggered. so according to this, and to your point, hope there is something wrong in client side.

            plz tell me what might be the issue for this...?

            thanks a lot for ur solutions..

            Regards
            Raj
            Last edited by Frinavale; Jun 15 '09, 01:36 PM. Reason: Added [quote] tags....changed from underline style.

            Comment

            • rajkumarbathula
              New Member
              • Aug 2008
              • 18

              #7
              hi frinavale

              my problem was solved by adding 2 script lines in my ascx page.

              and those lines are..
              Code:
              <script type='text/javascript'>   
                _spOriginalFormAction = document.forms[0].action;   
                _spSuppressFormOnSubmitWrapper=true;   
              </script>
              this solved my issue of postback on any number of time clicks on button.

              but another problem occured when i tried the same on another system..

              it is..i placed a text box and button on a ascx and i implemented ajax. every thing is working fine and even my code behind is also executing on button click. but the lines in my button click event ie., assign static text to textbox is of not affecting any thing.

              after the execution of code behind, i am not getting any output. i am getting the same old page when it was loaded before button click.

              even after execution of my code behind dont know why it is not refelecting in my page.

              plz save me.......
              Last edited by Frinavale; Jun 15 '09, 01:35 PM. Reason: Added code tags. Please post code in [code] [/code] tags.

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                I'm glad you solved your original problem!
                You should post a new thread for your new question but I have a feeling that you are setting the text again after the button click event...you may be setting this in your PreRender event or another event that occurs after the button click event in the asp.net page life cycle.

                Comment

                Working...