Recently I was asked the following questions in an interview:
Could someone explain the answer to these questions? I have no idea about either of them.
You can only have one ScriptManager
on a page. The script manager has several responsibilities, such as loading the MS Ajax libraries, creating proxy classes for web services, and enabling partial page rendering (e.g. UpdatePanel
) support. It doesn't make sense to have more than one per page, and you'll get an exception if you try to do this.
If you need to load additional scripts or references, in a user control for example, you can use the ScriptManagerProxy
class.
Regarding (1)
Yes and for (2) refer http://forums.asp.net/t/1073734.aspx link. One page can only have one script manager. Hope that helped :)
Watch your selectors, especially when you are working with .NET. You don't want to run the same selector multiple times. Instead you would want to define a javascript variable to hold the selector and then use that variable...that way jQuery is not having to find the same selector multiple times.
You can have 1 ScriptManager per page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With