Last post Jul 10, 2009 07:29 AM by ashish.k
Jul 09, 2009 05:18 AM|onlooker|LINK
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,,
Jul 09, 2009 07:07 AM|qwe123kids|LINK
Check the above link
Jul 10, 2009 02:48 AM|onlooker|LINK
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?
Jul 10, 2009 05:44 AM|Ashish.K|LINK
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.
Jul 10, 2009 06:04 AM|onlooker|LINK
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,,,
Jul 10, 2009 07:29 AM|Ashish.K|LINK
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.