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

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.

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

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 :)

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

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 :)

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

hmmmm... don't you think you should replace "this.RadioButton1.Text.ToString()" with "rb1"!!!! :)

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

No sites in mind... Just google it :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.