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 / guest

no we cant transfer data from one page to another page
using viewstate.
becouse in viewstate we can store only page level
information

Is This Answer Correct ?    21 Yes 17 No

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

Answer / abhinav saxena

Its right we cannot transfer the value from one page to
another using viewstate. Viewstate has the limit only on
one page. For transferring values we can use session or
querystring and interesting for more value transfer store
the values in datatable and store the table in a session.

Is This Answer Correct ?    4 Yes 0 No

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

Answer / william niver

Yes, you can get the PreviousPage ViewSate.

I have created two pages (Default.aspx and LandingPage.aspx)

Default.aspx has a LinkButton with a PostBackUrl pointing
to LandingPage.aspx.

Code Behind for Default.aspx:

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Load
ViewState("MyValue") = "I am a test value"
End Sub

Public Function GetViewState() As System.Web.UI.StateBag
Return ViewState
End Function

End Class

Code Behind for LandingPage.aspx:

Partial Class LandingPage
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Load
If PreviousPageViewState IsNot Nothing Then
If PreviousPageViewState("MyValue") IsNot
Nothing Then
'Value is retrieved from the PreviousPage
ViewState
MyBase.Controls.Add(New LiteralControl
(PreviousPageViewState("MyValue")))
End If
End If
End Sub

Private ReadOnly Property PreviousPageViewState() As
StateBag
Get
Dim ReturnValue As System.Web.UI.StateBag =
Nothing
If PreviousPage IsNot Nothing Then
Dim MyTypeObj As Object = DirectCast
(PreviousPage, Object)
For Each MethodObj As Reflection.MethodInfo
In PreviousPage.GetType.GetMethods()
If MethodObj.Name = "GetViewState" Then
ReturnValue = MethodObj.Invoke
(MyTypeObj, Nothing)
Exit For
End If
Next
End If
Return ReturnValue
End Get
End Property

End Class

Is This Answer Correct ?    6 Yes 2 No

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

Answer / guest

If someone is not sure about answer then please don't give
answer blindly.

Answer is 'NOOOOOOO....'

Is This Answer Correct ?    8 Yes 5 No

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

Answer / anil pandya

Yes, We can transfer one page data to another page using
viewstate,

The Way :-

The whole page data is stored in viewstate when you do a
page submit, at this point if you do server.transfer to
another page, it is like a postback on same page, you can
access both page data in view state.

To access the previous page data you have to use

System.Web.UI.Page prevPage = this.PreviousPage;

now all your controls are available with the same state they
were posted.

Is This Answer Correct ?    5 Yes 2 No

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

Answer / guest

View state is page level Access state managemenet
so viewstate object is available only after page_init() and
before page_load().

so we cannot pass it from one page to other page as a part
of request or any more......

Is This Answer Correct ?    13 Yes 11 No

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

Answer / vengatesh

not possible

Is This Answer Correct ?    6 Yes 4 No

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

Answer / sujata

A) yes we can do it by
1)Server.transfer(“Default2.aspx”);
2)with postbackURL property in the button event.

Source Page:

protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["NameOfUser"] != null)
Label1.Text = ViewState["NameOfUser"].ToString();
else
Label1.Text = "Not set yet...";

}
protected void Button1_Click(object sender, EventArgs e)
{
ViewState["NameOfUser"] = TextBox1.Text;
Label1.Text = TextBox1.Text;
Server.Transfer("Default2.aspx"); //Response.Redirect("Default2.aspx");(Cannot do wit response.redirect")

}

Target Page:

protected void Page_Load(object sender, EventArgs e)
{
Response.Write(((Label)PreviousPage.FindControl("Label1")).Text);
Label1.Text =" " + ((Label)PreviousPage.FindControl("Label1")).Text;

}

Is This Answer Correct ?    2 Yes 0 No

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

Answer / ali baba

No, It's not possible even if you are using the server.transfer.


If any one saying yes, ask them how?

Is This Answer Correct ?    12 Yes 11 No

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

Answer / jince p george

No ,surely it is not possible.we can solve this problem b
using session

Is This Answer Correct ?    3 Yes 2 No

Post New Answer

More ASP.NET Interview Questions

How to display validation messages in one control?

0 Answers  


Page Life Cycle in ASP.NET

2 Answers   Syntel,


What is Difference between Production Serves and Development Servers? And Suppose, m adding/deleting C# file in a project based on the Specific Requirement. These Files are Automatically updated in Production Servers? So Which tool is needed to do This One?

0 Answers  


How many web.copnfig can exists in a web application & which will be used ?

3 Answers   MMTS,


Give me one example of Web API Routing?

0 Answers  


Hi, I am working in a small software company in asp.net platform. I need to know how and what are all the task in asp.net will be assigned for the developers in mnc companies. Thanks in advance.

1 Answers  


How to disable cut, copy and paste in TextBox using jQuery in asp.net?

0 Answers   HCL,


Types of authentications in ASP.NET ?

9 Answers   Accenture, Roland, Shriram,


How you can stop the validation of ASP.NET controls from client side?

0 Answers   Sans Pareil IT Services,


Below is a code extract from an ASP.Net application. The code basically reads data from the “name” field in the “members” table and prints them onto the webpage. Using the assumptions provided, fill in the 4 blanks below so that the code will run correctly. ‘Assumptions: ‘conn_str is a variable that holds the connection string to the database ‘Objects dbcomm and dbread are already declared earlier dbcomm = New OleDbCommand("SELECT name FROM members", conn_str) dbread = dbcomm._______________ _____________________ response.write(_______________) _____________________ dbread.Close()

4 Answers   Techno Solutions,


Explain the server control events of asp.net ?

0 Answers  


Explain managed code an un-managed code.

0 Answers  


Categories