Pass data from a page

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2007
Posts: 6
Reputation: kally is an unknown quantity at this point 
Solved Threads: 0
kally kally is offline Offline
Newbie Poster

Pass data from a page

 
0
  #1
Aug 22nd, 2007
Hi,
Im new to ASP.NET. Im trying to create a webpage in VS.NET, with details like Name, Age, Designation, Marital Status (as labels) and a corresponding extBox for each of the label(For Marital Status, its a radio button each for Single and Married). There is also a SUBMIT button at the bottom. Once the USer enters the details, and clicks the SUBMIT button, it should throw up another page with the details that the user had enterd.
I have created 2 webpages with the required labels, textboxes etc. But Im confused on how to pass the data from the 1st page to the 2nd one.
Could anyone help??
Thanx.
Kally
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 72
Reputation: zmariow is an unknown quantity at this point 
Solved Threads: 1
zmariow's Avatar
zmariow zmariow is offline Offline
Junior Poster in Training

Re: Pass data from a page

 
0
  #2
Aug 22nd, 2007
Hi Kally,

You have many options. Here are the most common two options:
  1. ASP.NET Querystrings
  2. ASP.NET Session State

Each method has its benefits and drawbacks. Since you're a beginner I would suggest the first. Use a search engine to find tutorials on those; I'm sure you'll find plenty.

Cheers.
Last edited by zmariow; Aug 22nd, 2007 at 4:55 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 6
Reputation: kally is an unknown quantity at this point 
Solved Threads: 0
kally kally is offline Offline
Newbie Poster

Re: Pass data from a page

 
0
  #3
Aug 22nd, 2007
Hi Zmariow,
Thanks for your answer. I was able to find a way of passing data using a QueryString. But Im hab\ving one problem. While I was able to extract data from te text boxes and the dropdown list, Im unable to get the selected data from the radiobuttons. Could you help me with that?
Thanks.
Kally
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 72
Reputation: zmariow is an unknown quantity at this point 
Solved Threads: 1
zmariow's Avatar
zmariow zmariow is offline Offline
Junior Poster in Training

Re: Pass data from a page

 
0
  #4
Aug 22nd, 2007
Here's one way of doing it:

Create a string for every radiobutton and then check if the radiobutton is checked or not. If yes, then let the value of the string be true, otherwise false.

Next, pass the string value using the QueryString.

That's it
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 6
Reputation: kally is an unknown quantity at this point 
Solved Threads: 0
kally kally is offline Offline
Newbie Poster

Re: Pass data from a page

 
0
  #5
Aug 22nd, 2007
Thanx once again for your answer, but could you explain it a bit? Im not getting how to create a string for a radiobutton.
Thanks.
Kally
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 72
Reputation: zmariow is an unknown quantity at this point 
Solved Threads: 1
zmariow's Avatar
zmariow zmariow is offline Offline
Junior Poster in Training

Re: Pass data from a page

 
0
  #6
Aug 22nd, 2007
Assuming you have a radiobutton with name rb you can write:

  1. string rb_value;
  2. if(rb.Checked)
  3. rb_value = "true";
  4. else
  5. rb_value = "false";

You see
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 6
Reputation: kally is an unknown quantity at this point 
Solved Threads: 0
kally kally is offline Offline
Newbie Poster

Re: Pass data from a page

 
0
  #7
Aug 22nd, 2007
Actually, I have got 2 radiobuttons named RadioButton1 and RadioButton2;
I had created a string for each of them and made an IF clause earlier as below:
string rb1;
If (RadioButton1.Checked) Then rb1="true"
string rb2;
Elseif (RadioButton2.Checked) then rb2="true"
End If;
But im wondering how do I pass this to the query string. The query string is as below:

Response.Redirect("Webform2.aspx?name=" + this.TextBox1.Text + "&dept=" + this.TextBox2.Text + "&st=" + this.DropDownList1.SelectedItem.Text + "&mar=" + this.RadioButton1.Text.ToString());
Im not sure what I have to add along with RadioButton1
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 72
Reputation: zmariow is an unknown quantity at this point 
Solved Threads: 1
zmariow's Avatar
zmariow zmariow is offline Offline
Junior Poster in Training

Re: Pass data from a page

 
0
  #8
Aug 22nd, 2007
hmmmm... don't you think you should replace "this.RadioButton1.Text.ToString()" with "rb1"!!!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 6
Reputation: kally is an unknown quantity at this point 
Solved Threads: 0
kally kally is offline Offline
Newbie Poster

Re: Pass data from a page

 
0
  #9
Aug 23rd, 2007
Hi Zmariow,
I have kind of got the knack of how to use QueryStrings to pass data from 1 page to another. Im now trying to do the same using Session. One of the websites I checke in shows it using VB. Can be done using C# also? Could you direct me to some sites?
Thanks.
Kally
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 72
Reputation: zmariow is an unknown quantity at this point 
Solved Threads: 1
zmariow's Avatar
zmariow zmariow is offline Offline
Junior Poster in Training

Re: Pass data from a page

 
0
  #10
Aug 23rd, 2007
No sites in mind... Just google it
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC