Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 5th, 2011, 04:07 PM
Registered User
 
Join Date: Jan 2011
Posts: 9
Thanks: 6
Thanked 0 Times in 0 Posts
Default keep textbox values

hi
I have two webforms
webform1:http://i52.tinypic.com/vhqd6h.png
webform2:http://i53.tinypic.com/2m65w76.png
when a user fill the webform1 and get webform2( through submit )if user click return(get webform1) i want to show user the webform1 info that user filled first time.
(i want to keep webform1 info when user go to webform2 and return to webform1)
what should i do?
thanks
 
Old February 6th, 2011, 06:08 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You need some way to save the state of the form so you can do a server-side redirect.

For server state, you can use:

- Session state. Store the fields in the session in page 1, and reload them again when the page is requested

- Cookies - work similar to session state but are stored client side and are accessible at the server

- Save the data in the database and reload it when the page is requested again.

In other words, lots of options to choose from. You may want to Google a bit for each of these options to see their (dis)advantages.

Alternatively, you can use JavaScript's history.go(-1) to take the user back the previous page.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
123mehran (April 6th, 2011)
 
Old February 6th, 2011, 06:23 AM
Registered User
 
Join Date: Jan 2011
Posts: 9
Thanks: 6
Thanked 0 Times in 0 Posts
Default Session state

More Guidance in Session State
thanks
 
Old February 6th, 2011, 06:44 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Heuh?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
123mehran (April 6th, 2011)
 
Old February 6th, 2011, 06:51 AM
Registered User
 
Join Date: Jan 2011
Posts: 9
Thanks: 6
Thanked 0 Times in 0 Posts
Default

more guide in writing the code
i don't know what to type in page_load of webform1
 
Old February 6th, 2011, 06:56 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Did you follow my suggestion to Google a bit on ASP.NET Session state? It's quite a broad topic and a lot has been written about it. So, you're better off reading some stuff yourself so you get a good understanding of what it is and how to use it.

http://www.google.com/#sclient=psy&h...54f5edca559ee3

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
123mehran (February 6th, 2011)
 
Old February 6th, 2011, 08:45 AM
Registered User
 
Join Date: Jan 2011
Posts: 9
Thanks: 6
Thanked 0 Times in 0 Posts
Default Session state

Quote:
Originally Posted by 123mehran View Post
hi
I have two webforms
webform1:http://i52.tinypic.com/vhqd6h.png
webform2:http://i53.tinypic.com/2m65w76.png
when a user fill the webform1 and get webform2( through submit )if user click return(get webform1) i want to show user the webform1 info that user filled first time.
(i want to keep webform1 info when user go to webform2 and return to webform1)
what should i do?
thanks
please help me to write the code for save webform 1 texboxes's values
i've tried but didn't get any result
thanks
Code:
Public Class webform1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Response.Redirect("Result.aspx?name=" + Name.Text + "&lastname=" + Lastname.Text + "&Idnum=" + IDNum.Text)
    End Sub
End Class
 
Old February 6th, 2011, 08:59 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Not sure I understand what you're asking. is this code from the first page (e.g. how you pass data to the "confirm" page) or is this your attempt to pass the values back to the first page?

Either way, the idea should work. But, depending on your current setup, on Page 2 you shouldn't get the value from a TextBox but from a query string. E.g.:

Code:
Protected Sub Goback_Click(ByVal sender As Object, ByVal e As EventArgs) Handles GoBack.Click
        Response.Redirect("Page1.aspx?name=" + Request.QueryString.Get("Name"))
End Sub
Then in Page1 you can try to prefill the text box from the query string:

Code:
 
If Not String.IsNullOrEmpty(Request.QueryString.Get("Name"))
  TextBox1.Text = Request.QueryString.Get("Name")
End If
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
123mehran (February 6th, 2011)
 
Old April 6th, 2011, 07:02 AM
Authorized User
 
Join Date: Dec 2004
Posts: 69
Thanks: 0
Thanked 5 Times in 5 Posts
Send a message via Yahoo to whiterainbow
Default

You can create your own collection class and store it in the session and when the page is loaded, you can check whether the session is null or not and bind the data from your session to the controls by converting it to the collection object too...

Code:
public class Person
{
public string FirstName
{get; set;}

public string LastName
{get; set;}
}
In your Page's Code Behind:

Code:
partial class Page1:Web.Form
{

public Person myPerson
{get; set;}

protected void button1_click(object sender, EventArgs e)
{

Person p=new Person();
p.FirstName=txtFirstName.Text;
p.LastName=txtLastName.Text;

Session["Person"]=p;

}

protected void Page_Load(object sender, EventArgs e)
{

if(Session["Person"]!=null)
{
myPerson=(Person)Session["Person"];

txtFirstName.Text=myPerson.FirstName;
txtLastName.Text=myPerson.LastName;

}
}
}
Happy Coding.
__________________
Thanks in advance.

Regards,

Senthil Kumar M.

Last edited by whiterainbow; April 6th, 2011 at 07:05 AM..
The Following User Says Thank You to whiterainbow For This Useful Post:
123mehran (April 6th, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
write the values of textbox to a file sandhyamn Pro JSP 1 May 23rd, 2007 10:04 AM
Sum Textbox Values Snuffles ASP.NET 2.0 Basics 1 April 13th, 2007 01:36 PM
Taking values from textbox derekl ASP.NET 1.0 and 1.1 Professional 3 February 20th, 2006 08:30 AM
concatinating values in textbox crmpicco Javascript How-To 1 July 1st, 2005 09:29 AM
textbox with numerical values must C# 1 August 7th, 2003 12:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.