How to pass multiple values across asp.net web froms C#

Post Reply
User avatar
Trebor29
Lieutenant
Lieutenant
Posts: 75
Joined: Thu Apr 29, 2010 12:34 am

How to pass multiple values across asp.net web froms C#

Post by Trebor29 » Thu Mar 29, 2012 9:57 pm

Hi all,

Im having a bit of a headache trying to pass multiple textbox.text values across asp.net pages!

The forms are built to display on mobile browsers, so to provide better user expeience I have broken up the Registration across 3 web forms. form1 - contact info, form2 - auth info i.e. password and PIN, form3 - payment info...

I need to pass all values from form1 and form2 over to form3 so that they can all be passed over to my registration class at the same time so I only need to make one new class object. Entering the class on three separate occasions means a new class object has to be made each tme, which clears the data already held!
Also I cant commit the data after each form1,2 and 3 because if something goes wrong alf way through, half the data still gets added to the database, making it inconsistent!

I am trying not to use 'Session' as I already am using one to control secure folder access and am not keep to use anymore if possible. Thinking about speed at times of high visitor times!

Little help? :biggrin:

P.S. I have tried:

Response.Redirect("~/Mobile/Register_2.aspx?fName=" + Server.UrlEncode(firstNameTextBox.Text));
and
firstName = Request.QueryString["fName"];

But this is only a single value!!!! at max I want to pass 11 values..
User avatar
Herath
Major
Major
Posts: 417
Joined: Thu Aug 05, 2010 7:09 pm

Re: How to pass multiple values across asp.net web froms C#

Post by Herath » Thu Mar 29, 2012 11:47 pm

Using Session state is what I see as the easiest to deal with. It is going to get messy with query strings.

And you might be able to use static variables in the class you are using to create the object. I haven't tried it though. But I doubt that it is possible to do so like with the Session State.

How about changing visibility on pressing next?. I haven't used ASP.Net for anything other than an assignment. It was a pain to deal with. :D. I still can't figure out how can I get the full control over what will be sent to the browser as it is possible in PHP.
User avatar
Trebor29
Lieutenant
Lieutenant
Posts: 75
Joined: Thu Apr 29, 2010 12:34 am

Re: How to pass multiple values across asp.net web froms C#

Post by Trebor29 » Fri Mar 30, 2012 12:46 am

Ye im doing this application for an assignment as well, and I have to say it has been a bit of a buggar to get to grips with...

Ive manage to achieve passing muliple values using the httpUtility class:

Form1:

Code: Select all

 Response.Redirect(string.Format("~/Mobile/Register_2.aspx?value1={0}&value2={1}&value3={2}&value4={3}&value5={4}&value6={5}&value7={6}&value8={7}&value9={8}&value10={9}&value11={10}",
                       HttpUtility.UrlEncode(firstName),
                       HttpUtility.UrlEncode(lastName),
                       HttpUtility.UrlEncode(address1),
                       HttpUtility.UrlEncode(address2),
                       HttpUtility.UrlEncode(address3),
                       HttpUtility.UrlEncode(postcode),
                       HttpUtility.UrlEncode(country),
                       HttpUtility.UrlEncode(mobileNumber),
                       HttpUtility.UrlEncode(email),
                       HttpUtility.UrlEncode(pWordTextBox.Text),
                       HttpUtility.UrlEncode(payPINTextBox.Text)));
Then is Form 2 Request.QueryString:

Code: Select all

firstName = Request.QueryString["value1"];
            lastName = Request.QueryString["value2"];
            address1 = Request.QueryString["value3"];
            address2 = Request.QueryString["value4"];
            address3 = Request.QueryString["value5"];
            postcode = Request.QueryString["value6"];
            country = Request.QueryString["value7"];
            mobileNumber = Request.QueryString["value8"];
            email = Request.QueryString["value9"];
Ive got a new issue now though, its one after another! lol :laughing:
Post Reply

Return to “ASP & ASP.Net”