Monday, 6 August 2012

New Internview Quest

Basic Logic for prograamming
http://www.programmingsimplified.com/c-program-examples

What is crosspage posting in ASP.NET and what is its use

Answer:

In ASP.NET,when we click a button Web page post the page to itself.

But cross page posting is to post one page to another page.

This is used generally in a multi page forms where we put previous next

button and these buttons are used to post one form data to another form

so that last form can have the full data.

Cross page posting can be done in the following ways:

A.Using Button and Postback url

<asp:Button ID="Button1" runat="server"

Text="" PostBackUrl="~/DestinationPage.aspx" />

B.Using server.Transfer

server.Transfer has following three overload.

1. Server.Transfer("site url");

2. Server.Transfer("site url",true);

3. Server.Transfer(CustomHandler,true);

To Check for CrossPagePostback check the following in the destination page

1.Page.PreviousPage is NOT NULL,

2.PreviousPage.IsCrossPagePostback is true

TextBox txtName = (TextBox)previousPage.FindControl("txtName");

Quest 2:
What is sequence of Load and Init event for Page MasterPage UserControl ChildUserControl
Answer:

Some facts to remeber before answering this question
Master page is First Child Control of Page.
Parent is loaded first but child is initialised(init) first
Init happens before Load

Init event sequence is as below:

ChildUserControl_Load
UserControl_Load
MasterPage_Load
Page_Load

Page_Load event sequence is as below:

Page_Load
MasterPage_Load
UserControl_Load
ChildUserControl_Load

Quest 3
What are the advantage and disadvantage of cross page posting using Server.Transfer
Answer:

Advantages :

1.It is faster than Response.Redirect method as one less round trip is there.
2.We can access previous page controls and pass value from

previous to current page using context item.
Disadvantages:
1.Url will not change and remain as previous page so users might get confused.
2.If we refresh the page by mistake the parent page will be shown.
3.This can not be used for external link or page

Quest 4
Can a page inherit two master page in ASP.NET
Answer:

Yes.
One master page can inherit a second master page in ASP.NET.
So ,a single page cannot inherit two different master pages directly.
But a single page inherit two different master pages indirectly.

Quest5

What is difference between ASP.NET Session and WCF Session

Answer:

1.ASP.NET sessions are initiated by server

while WCF sessions are initiated by WCF Client.

2.ASP.NET sessions data can be accessed in unordered way

but In WCF session Messages delivered during a session

are processed in the order in which they are received.

3.ASP.NET has a general data storage mechanism for session

but In WCF there is no such data storage.

Below is a sample WCF class with Required Session Mode

[ServiceContract(Namespace="http://abc.com", SessionMode=SessionMode.Required)]

public interface ICalculatorSession

{ }

No comments:

Post a Comment