Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.net Interview questions

Tags:

asp.net

Recently I was asked the following questions in an interview:

  1. How will you do performance optimization over your jQuery in ASP.NET?
  2. How many script managers can you have in an ASP.NET application? Why? (AJAX related)

Could someone explain the answer to these questions? I have no idea about either of them.

like image 415
Amutha Avatar asked Apr 10 '10 14:04

Amutha


3 Answers

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.

like image 61
richeym Avatar answered Oct 29 '22 16:10

richeym


Regarding (1)

  1. Use tools like firebug or dynatrace to do the profiling and digging the code.
  2. JQuery is not out of nowere its JavaScript so one has to know it well for optimization.
  3. Adhere to good JavaScript coding practices that helps big time.
  4. 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 :)

like image 29
Anil Namde Avatar answered Oct 29 '22 18:10

Anil Namde


  1. 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.

  2. You can have 1 ScriptManager per page.

like image 32
Erikk Ross Avatar answered Oct 29 '22 17:10

Erikk Ross