Interview Questions on ASP.NET Page Navigation

Q : What are different page navigation techniques in ASP.NET?

Ans : Hyperlink control : Navigate to another page.
Response.Redirect : Navigate to another page from code. This is equivalent to clicking a hyperlink.
Server.Transfer : End the current Web form and begin executing a new Web form. This method works only when navigating to a Web Forms page (.aspx).
Server.Execute : Begin executing a new Web form while still displaying the current Web form. The contents of both forms are combined. This method works only when navigating to a Web Forms page (.aspx).
Window.Open script method : Display a page in a new browser window on the client.

Q : What is the difference between Response.Redirect and Server.Transfer?

Ans : 1. SWhen we use Server.Transfer the redirection happens on the server where as when we use Response.Redirect the redirection happens from the browser.

2. Server.Transfer is faster as there is no round trip involved while navigating from one webform to another webform. Response.Redirect is slower than Server.Transfer as there is round trip from the server to the client browser.

3. Server.Transfer works only with .aspx files where as Response.Redirect works with .aspx and .Htm pages.

4. Server.Transfer will work with files on the same web server. You can't use Server.Transfer to send the user to an external site where as Response.Redirect can do that.

5. Server.Transfer does not update the URL in the browser. For example when you navigate from WebForm1.aspx to WebForm2.aspx using Server.Transfer the URL in the browser still shows WebForm1.aspx while you are actually looking at WebForm2.aspx. Response.Redirect updates the URL in the browser.

Q : What is the use of Server.Execute method?

Ans : Server.Execute method is used to process a second Web form without leaving the first Web form. This technique lets you direct the results from a Web form to a region on the current page.

Q : Is it possible to send a webform's QueryString, ViewState, and event procedure information to another webform?

Ans : Yes, we can use Server.Transfer or Server.Execute to send a webform's QueryString, ViewState, and event procedure information to another webform.

For this to work you have to set the preserveForm argument to True.To be able to read one Web form’s ViewState from another, you must first set the EnableViewStateMac attribute in the Web form’s Page directive to False. By default, ASP.NET hashes ViewState information, and setting this attribute to False disables that hashing so that the information can be read on the subsequent Web form.

 

  « Previous    | Next »
     
Leave a Reply
Name (required)
Email (will not be published) (required)
Web Site

List of Top Hospitals in India