locked
How to add another control to aspx when my custom server control dropped to that page,,, RRS feed

  • Question

  • User-404834630 posted

    Hi,,, how can I check if ScriptManager control exists in an aspx page, and programitically add it to that page if there is no ScriptManager control,,,I need to do it in <b>design-time</b>, when my control will be dropped to a page,, 

    Thursday, July 9, 2009 5:18 AM

Answers

  • User2136026738 posted

     Hi,

         Just Place Panel in master page and OnInit of the control just check if the Scriptmanager Exist else using the same loop you can find this Panel in Page and add the Script Manager to it.But it has to be done onInit.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 10, 2009 7:29 AM

All replies

  • User-1659704165 posted

    Hi,

    http://forums.asp.net/p/1039254/1777798.aspx

    Check the above link

    Thursday, July 9, 2009 7:07 AM
  • User-404834630 posted

    thanks a lot,,, but I've seen that topic,,, it's about how to add scriptmanager dynamically in run-time,,, but I can't do it,,, 'cause scriptmanager should be added from my custom control's code,,, and that's why I can NOT get PreInit handler,,, so, I have to do it in design-time,,, any ideas?

    Friday, July 10, 2009 2:48 AM
  • User2136026738 posted

     Hi,

    You can access CustomControl.Page property and itrate through the Controls Property of this Page and find if control type is ScriptManager.

    //In Coustom control you can have this code.
    
    for(int = 0;i<this.Page.Controls.Count;i++)
    {
    if(this.Page.Controls[i].ToString() = "ScriptManager")
       //then do following
    //Please consider a scenario where a control can also have Controls property like a //user control or Masterpage in this case you have to write a recurssive method to //check all the inner controls of a perticular control.
    
    //Note: please check the return value of the this.Page.Controls[i].ToString() for ScriptManager ans write 
    }
    


     

    Let me know if you find any difficulty in doing this.

     

    Friday, July 10, 2009 5:44 AM
  • User-404834630 posted

    thank u,,, yes using your code I can check if ScriptManager exists in a page ,,, but after I can't add scriptmanager control if it doesn't exist there,,, I need to do it in design-time when my custom control dropped to form,,,

    Friday, July 10, 2009 6:04 AM
  • User2136026738 posted

     Hi,

         Just Place Panel in master page and OnInit of the control just check if the Scriptmanager Exist else using the same loop you can find this Panel in Page and add the Script Manager to it.But it has to be done onInit.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 10, 2009 7:29 AM