can we transfer data from one page to another page using
viewstate if so how?if not y?
Answer Posted / 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 |
Post New Answer View All Answers
What is the difference between sealed vs static class?
explain code with datachaching with example
How many types of session in ASP.NET
How to find out what version of asp.net I am using on my machine?
What are the built-in objects in asp.net?
How do I force the dispose method to be called automatically, as clients can forget to call dispose method?
while developing webservices if i want some users to use my webservice only how can i give security to my webservice?
What do you mean by query string?
Difference between DataGid and Girdview? Difference b/w .Net 2.0, 3.0 and 3.5 ? Diff b/w dispose & Finialize Methods?
Which is better session or viewstate?
What is the difference between localization and globalization?
Explain the difference between globalization and localization techniques
How do I debug an asp.net application that was not written with visual studio.net and that does not use code-behind?
What is content place holder?
Explain how can we inherit a static member?