Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi can u help me how to call ScriptManager.RegisterStartupScript in class
Posted
Updated 8-Aug-11 21:41pm
v2
Comments
RaviRanjanKr 9-Aug-11 3:17am    
Not Clear. please give more information about your question. :)

C#
private void EnsurePanelFix()
      {
        if (this.Page.Form != null)
        {
          String fixupScript = @"
          _spBodyOnLoadFunctionNames.push(""_initFormActionAjax"");
          function _initFormActionAjax()
          {
          if (_spEscapedFormAction == document.forms[0].action)
          {
            document.forms[0]._initialAction =
              document.forms[0].action;
          }
        }
        var RestoreToOriginalFormActionCore =
          RestoreToOriginalFormAction;
        RestoreToOriginalFormAction = function()
        {
        if (_spOriginalFormAction != null)
        {
          RestoreToOriginalFormActionCore();
          document.forms[0]._initialAction = document.forms[0].action;
        }
        }";
        ScriptManager.RegisterStartupScript(this,
          typeof(nameofclass/namespace), "UpdatePanelFixup",
          fixupScript, true);
        }
      }
    }
}
 
Share this answer
 
Given that you didn't tag your question ASP.NET, I'm not sure what you're asking. Either way, I am confused why you're incapable of using google to read the examples on MSDN, etc. Do you have a more specific question, are you stuck with something ? One guess would be that you want to do this inside a class that's not a Page derived class. I would suggest this is almost always a bad idea, and you're better off improving your design, but you can pass the Page instead through to your class to do that if you want.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900