Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


can we transfer data from one page to another page using
viewstate if so how?if not y?

Answers were Sorted based on User's Feedback



can we transfer data from one page to another page using viewstate if so how?if not y?..

Answer / leoiser

No.from my knowledge can not.Bcos viewstate life time is in
single page.So while going to another page first page
viewstate end already.

Is This Answer Correct ?    97 Yes 32 No

can we transfer data from one page to another page using viewstate if so how?if not y?..

Answer / gurvinder singh

This is not possible using view state , however we can
acheive this by using session .View state has only page
scope.

Is This Answer Correct ?    64 Yes 19 No

can we transfer data from one page to another page using viewstate if so how?if not y?..

Answer / vijaykumar

Yes.
View state is page specific; it contains information about
controls embedded on theparticular page. ASP.NET 2.0
resolves this by embedding a hidden input field
name,__POSTBACK . This field is embedded only when there is
an IButtonControl on thepage and its PostBackUrl property is
set to a non-null value. This field contains the viewstate
information of the poster page. To access the view state of
the poster page, you canuse the new PreviousPage property of
the page

Page poster = this.PreviousPage;

Then you can find any control from the previous page and
read its state

Label posterLabel =(Label)poster.findControl("myLabel");
string lbl = posterLabel.Text;

This cross-page post back feature also solves the problem of
posting a Form to multiplepages, because each control, in
theory, can point to different post back URL.

Is This Answer Correct ?    41 Yes 9 No

can we transfer data from one page to another page using viewstate if so how?if not y?..

Answer / jayamala

I think its not possible using viewstate.To pass data from
one page to another we are using session variable.

Is This Answer Correct ?    38 Yes 17 No

can we transfer data from one page to another page using viewstate if so how?if not y?..

Answer / ashutosh sharma

yes we can by sessions, server.transver

Is This Answer Correct ?    23 Yes 6 No

can we transfer data from one page to another page using viewstate if so how?if not y?..

Answer / vipin agrawal

yes we can do it by cross page posting (cross page
viewstate)

here is the code:

Source page code:
----------------
public partial class ViewStateContainer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ViewState["Page1"] = "Page1 ViewState";
Server.Transfer("AccessViewState.aspx");
}

/*StateBag class: This class is the primary storage
mechanism for all HTML and Web server controls.
It stores attribute/value pairs as strings associated
with the control. It tracks changes to these
attributes only after the OnInit method is executed for
a page request, and saves the changes
to the page's or control's viewstate.*/
public StateBag ReturnViewState()
{
return ViewState;
}

}

Target page code:
----------------

public partial class AccessViewState : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
if (PreviousPageViewState != null)
{
Label1.Text = PreviousPageViewState
["Page1"].ToString();
}
}
Response.Write(((Label)PreviousPage.FindControl
("Label1")).Text);

}

private StateBag PreviousPageViewState
{
get
{
StateBag returnValue = null;
if (PreviousPage != null)
{
Object objPreviousPage = (Object)
PreviousPage;
MethodInfo objMethod =
objPreviousPage.GetType().GetMethod
("ReturnViewState");
return (StateBag)objMethod.Invoke
(objPreviousPage, null);
}
return returnValue;
}
}

}

Is This Answer Correct ?    11 Yes 0 No

can we transfer data from one page to another page using viewstate if so how?if not y?..

Answer / prasad bakshi

This is VERY MUCH POSSIBLE to access viewstate on another
page. This is only possible when you use SERVER.TRANSFER

Try this out.

Create a textbox control on page1.aspx and have a button.

Onclick of button put this code in page load event of
Page2.aspx.

/*****************************************************/
Page Poster = this.PreviousPage;

TextBox txtNewTest = (TextBox)Poster.FindControl("txtTest");

sDisplay = txtNewTest.Text;

Response.Write(sDisplay);
/*****************************************************/

Is This Answer Correct ?    11 Yes 2 No

can we transfer data from one page to another page using viewstate if so how?if not y?..

Answer / shamme

viewstate values stored in present page...once use
server.transfer the view state values was out....so not
possible to transfer data from one page to another page...

Is This Answer Correct ?    10 Yes 3 No

can we transfer data from one page to another page using viewstate if so how?if not y?..

Answer / tejavishu

By using viewstate it is not possible.sure it is not
possible.bcoz its comes under the pagelevel state manage
ment.to maintaning the state in page it self we are using
the view state.

Is This Answer Correct ?    20 Yes 14 No

can we transfer data from one page to another page using viewstate if so how?if not y?..

Answer / radhika kilaru

No, we can't pass the data from one page to another using
viewstate. Because, view state will be maintained between
page postbacks only

Is This Answer Correct ?    6 Yes 1 No

Post New Answer

More ASP.NET Interview Questions

What tag do you use to add a hyperlink column to the DataGrid?

2 Answers   Siebel Systems,


If Instancing = Single use for ActiveX Exe, how will this be executed if there are 2 consecutive client requests ?

0 Answers   DELL,


Question asked by one of interviewer in panal is given below: We have 2 user control on same page ,1st user control contains textbox and a button while 2nd user control have label. when ever we click on button click of 1st custom control button the value of the textBox will get updated into Label of 2nd custom control. How to do this.Your help will be appreciated.

1 Answers  


What layout mode is the default when a new Web Form is created? a) GridBagLayout b) GridLayout c) FlowLayout d) FormLayout

2 Answers   Syntax Softtech,


what are the types of ASP objects ?

7 Answers   Satyam,


Tell About Global.asax ?

3 Answers   Keane India Ltd,


What is WCF? Pls Explain clearly with exmple.

3 Answers   HCL, iGate,


what is view stat how it is use ?

2 Answers   Amazon,


To display data in a Repeater control which templete is provided ?

4 Answers   Siebel,


How Can assign alias name for ASP.NET Web API Action?

0 Answers  


What is syntax code to send email from an asp.net application?

0 Answers  


if you disable view state of a textbox will it maintain data during postbacks.if yes reason

9 Answers   FactorH, Jindal, Oxi Infotech,


Categories