tags:

views:

205

answers:

1

am creating a web page that allows users to enter their product name and purchase date.if they do? i check these inputs against what i have in the database and if theres a match, i display the next page and parsing the entered values into another textbox in the next page.

am using response.redirect("nextpagename.aspx") to display the next page after the button is clicked and the above is corect. how do i send the values from the text box to the other page to be displayed in the textboxes?

i tried a get items form the first page and in the page load on the next page i declarwe a new instance of the form and pass the getitems from the previous page to the textbxes i want them to be displayed in the next form. however the fields display notheing and yet the code dosent catch anyerrors.

my guess is am passing an empty string..am i right? if i am howdo i fix this..

more details in the code below...

protected void Button1_Click(object sender, EventArgs e)
    {
        string strConn;

        strConn = "Provider=MIcrosoft.Jet.OLEDB.4.0;data Source=" +
            Server.MapPath("App_Data/test.mdb");

        OleDbConnection mDB = new OleDbConnection(strConn);
        mDB.Open();

        prodSnStr = pSnTextBox.Text;
        purDate = Convert.ToDateTime(purDateTextBox.Text);

        productClass aProduct = new productClass();

        if (aProduct.Prods(mDB, prodSnStr, purDate))
        {
            //Session["userId"] = Login1.UserName.ToString();

            Response.Redirect("Warranty.aspx");

        }
        else
        {
            //e.Authenticated = false;
        }




    }

    public string getProd()
    {
        return prodSnStr;
    }
    public DateTime getDate()
    {
        return purDate;
    }

In the next page that loads i have this code there

public partial class Warranty : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Warranty1 war1 = new Warranty1();


        pSNoTextBox.Text = war1.getProd();
        dateTextBox.Text = war1.getDate().ToString();
    }
+1  A: 

Pass it as parameter:

Response.Redirect("Warranty.aspx?value=" + Server.UrlEncode(someTextBox.Text));

And in the Warranty.aspx page:

string value = Request["value"];
Darin Dimitrov
Makes absolute sence. however how do i do this for more than one value from a text box and how do i pass these values to the text boxes in the next form?
Selase
If you have many values and you don't want to pass all of them as Url parameters you could create a custom object that will hold these values and store it in the `Session`.
Darin Dimitrov
if i use a session, how do i pass the values to the textbox in the new form..?Below is how am keeping the files in the session then running the next formsession["prodsSn"] = pSnTextBox.text;session["purDate"] = purDateTextBox.text.ToString();response.redirect("warranty.aspx");in page load of the next form what is the code to pass the values in the session to the new textboxes?
Selase