944,043 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 3489
  • ASP.NET RSS
Aug 22nd, 2007
0

Pass data from a page

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kally is offline Offline
6 posts
since Aug 2007
Aug 22nd, 2007
0

Re: Pass data from a page

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.
Reputation Points: 14
Solved Threads: 1
Junior Poster in Training
zmariow is offline Offline
69 posts
since Aug 2007
Aug 22nd, 2007
0

Re: Pass data from a page

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kally is offline Offline
6 posts
since Aug 2007
Aug 22nd, 2007
0

Re: Pass data from a page

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
Reputation Points: 14
Solved Threads: 1
Junior Poster in Training
zmariow is offline Offline
69 posts
since Aug 2007
Aug 22nd, 2007
0

Re: Pass data from a page

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kally is offline Offline
6 posts
since Aug 2007
Aug 22nd, 2007
0

Re: Pass data from a page

Assuming you have a radiobutton with name rb you can write:

ASP.NET Syntax (Toggle Plain Text)
  1. string rb_value;
  2. if(rb.Checked)
  3. rb_value = "true";
  4. else
  5. rb_value = "false";

You see
Reputation Points: 14
Solved Threads: 1
Junior Poster in Training
zmariow is offline Offline
69 posts
since Aug 2007
Aug 22nd, 2007
0

Re: Pass data from a page

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kally is offline Offline
6 posts
since Aug 2007
Aug 22nd, 2007
0

Re: Pass data from a page

hmmmm... don't you think you should replace "this.RadioButton1.Text.ToString()" with "rb1"!!!!
Reputation Points: 14
Solved Threads: 1
Junior Poster in Training
zmariow is offline Offline
69 posts
since Aug 2007
Aug 23rd, 2007
0

Re: Pass data from a page

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kally is offline Offline
6 posts
since Aug 2007
Aug 23rd, 2007
0

Re: Pass data from a page

No sites in mind... Just google it
Reputation Points: 14
Solved Threads: 1
Junior Poster in Training
zmariow is offline Offline
69 posts
since Aug 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: asp.net with MYSQL
Next Thread in ASP.NET Forum Timeline: get HTML table property on page load event





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC