ASP.net Interview questions
Recently I was asked the following questions in an interview:
- How will you do performance optimization over your jQuery in ASP.NET?
- How many script managers can you have in an ASP.NET applicatio开发者_开发百科n? Why? (AJAX related)
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)
- Use tools like firebug or dynatrace to do the profiling and digging the code.
- JQuery is not out of nowere its JavaScript so one has to know it well for optimization.
- Adhere to good JavaScript coding practices that helps big time.
- Always remember that each JS file and line of code you write is transfered to client for execution so be aware of it while writing code as this cas cause issues. So if you decide to include 4 JS file sum sized to 400 KB emans u are putting burdon on the client especially if he is on slow lines.
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.
You can have only one ScriptManager per page
A page can contain only one script manager in its hierarchy according to the documentation. For jQuery optimization, it is important to use minified versions of all JS files and profiling tools such as Firebug are helpful.
- This would be an normal statement for performance optimization, Performance is an important aspect of the modern day web application development. Not only does it make a site seamless to use, but also increases the scalability of the website and makes it future proof. In this article, we will look at various aspects of improving the performance of ASP.NET web applications. We will only concentrate on the browser/web server side performance as opposed to server/app server/database server performance optimizations.
- You can have only one scriptmanager per page otherwise you will get an exception when you run the application.
you can also refer this link for Interview questions and answers.
精彩评论