User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 391,639 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,816 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 1661 | Replies: 9
Reply
Join Date: Aug 2007
Posts: 6
Reputation: kally is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kally kally is offline Offline
Newbie Poster

Pass data from a page

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Posts: 70
Reputation: zmariow is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
zmariow's Avatar
zmariow zmariow is offline Offline
Junior Poster in Training

Re: Pass data from a page

  #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 3:55 am.
Reply With Quote  
Join Date: Aug 2007
Posts: 6
Reputation: kally is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kally kally is offline Offline
Newbie Poster

Re: Pass data from a page

  #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  
Join Date: Aug 2007
Posts: 70
Reputation: zmariow is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
zmariow's Avatar
zmariow zmariow is offline Offline
Junior Poster in Training

Re: Pass data from a page

  #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  
Join Date: Aug 2007
Posts: 6
Reputation: kally is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kally kally is offline Offline
Newbie Poster

Re: Pass data from a page

  #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  
Join Date: Aug 2007
Posts: 70
Reputation: zmariow is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
zmariow's Avatar
zmariow zmariow is offline Offline
Junior Poster in Training

Re: Pass data from a page

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

string rb_value;
if(rb.Checked)
    rb_value = "true";
else
    rb_value = "false";

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

Re: Pass data from a page

  #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  
Join Date: Aug 2007
Posts: 70
Reputation: zmariow is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
zmariow's Avatar
zmariow zmariow is offline Offline
Junior Poster in Training

Re: Pass data from a page

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

Re: Pass data from a page

  #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  
Join Date: Aug 2007
Posts: 70
Reputation: zmariow is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 1
zmariow's Avatar
zmariow zmariow is offline Offline
Junior Poster in Training

Re: Pass data from a page

  #10  
Aug 23rd, 2007
No sites in mind... Just google it
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 1:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC