Answered by:
how to send data one to page to last(third page) in asp.net web form

Question
-
User-1996127953 posted
I m working in asp.net
I want to first page data display on last page I m using query string
problem is first page data is not pass the last page give an error object referance not set to an object
PersonalDetail.aspx 1 page
<form id="form1" runat="server"> <h1 style="text-align: center">Personal Information:</h1> FirstName:<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please Enter Your Name" ControlToValidate="txtFirstName" ForeColor="Red"></asp:RequiredFieldValidator> <div style="margin-left: 5px"></div> LastName:<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please Enter Your LastName" ControlToValidate="txtLastName" ForeColor="Red"></asp:RequiredFieldValidator> <div style="margin-left: 5px"></div> Date Of Birth:<asp:Calendar ID="txtcalender" runat="server"></asp:Calendar> <div style="text-align:center"> <asp:Button ID="Button1" runat="server" Text="Next" OnClick="Button1_Click" /> </div> </form>
PersonalDetail.aspx.cs
protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("ContactInformation.aspx?FirstName=&LastName=&DateofBirth=" + txtFirstName.Text +txtLastName.Text + txtcalender.SelectedDate); }
contactinformation.aspx 2 page
<form id="form1" runat="server"> <h1 style="text-align: center">Contact Information:</h1> EmailId:<asp:TextBox ID="txtEmailid" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please Enter Your EmailId" ControlToValidate="txtEmailid" ForeColor="Red"></asp:RequiredFieldValidator> <div style="margin-left: 5px"></div> MobileNo:<asp:TextBox ID="txtMno" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please Enter Your MobileNo" ControlToValidate="txtMno" ForeColor="Red"></asp:RequiredFieldValidator> <div style="margin-left: 5px"></div> Password:<asp:TextBox ID="txtPass" runat="server" TextMode="Password" ></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Please Enter Your Password" ControlToValidate="txtPass" ForeColor="Red"></asp:RequiredFieldValidator> <div style="margin-left: 5px"></div> <div style="text-align:center"> <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" /> </div> </form>
contactinformation.aspx.cs
protected void Page_Load(object sender, EventArgs e) { string FirstName = Request.QueryString["FirstName"].ToString(); string LastName = Request.QueryString["LastName"].ToString(); string DateofBirth = Request.QueryString["DateofBirth"].ToString(); } protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("DisplayPage.aspx?EmailId=&MobileNo=" + txtEmailid.Text + txtMno.Text); }
DisplayPage.aspx.cs 3 Page
protected void Page_Load(object sender, EventArgs e) { string FirstName = Request.QueryString["FirstName"].ToString(); here give the error object referance not set to an object string LastName = Request.QueryString["LastName"].ToString(); here give the error object referance not set to an object string DateofBirth = Request.QueryString["DateofBirth"].ToString(); here give the error object referance not set to an object string EmailId = Request.QueryString["EmailId"].ToString(); string MobileNo = Request.QueryString["MobileNo"].ToString(); Response.Write(FirstName); Response.Write(LastName); Response.Write(DateofBirth); Response.Write(EmailId); Response.Write(MobileNo); }
display the personal information data and contact information data display on the last page(DisplayPage.aspx.cs)
what I m doing wrong?
help
Friday, May 8, 2020 12:16 PM
Answers
-
User409696431 posted
First, you are not passing the parameter values in the query strings correctly.
Response.Redirect("ContactInformation.aspx?FirstName=&LastName=&DateofBirth=" + txtFirstName.Text +txtLastName.Text + txtcalender.SelectedDate);
Response.Redirect("DisplayPage.aspx?EmailId=&MobileNo=" + txtEmailid.Text + txtMno.Text);You need to put the parameter values after the = sign for each parameter:
Response.Redirect("DisplayPage.aspx?EmailId=" + txtEmailid.Text + "&MobileNo=" + txtMno.Text);
You need to fix the first one similarly.
Second problem:
You are not passing the values from the first page to the third page at all. You need to add the values you captured from the first page to the query string going to the third page.
Response.Redirect("DisplayPage.aspx?EmailId=" + txtEmailid.Text + "&MobileNo=" + txtMno.Text + "&FirstName" + FirstName + "&LastName" + LastName + "&DateofBirth" + DateofBirth);
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, May 9, 2020 5:27 PM
All replies
-
User409696431 posted
First, you are not passing the parameter values in the query strings correctly.
Response.Redirect("ContactInformation.aspx?FirstName=&LastName=&DateofBirth=" + txtFirstName.Text +txtLastName.Text + txtcalender.SelectedDate);
Response.Redirect("DisplayPage.aspx?EmailId=&MobileNo=" + txtEmailid.Text + txtMno.Text);You need to put the parameter values after the = sign for each parameter:
Response.Redirect("DisplayPage.aspx?EmailId=" + txtEmailid.Text + "&MobileNo=" + txtMno.Text);
You need to fix the first one similarly.
Second problem:
You are not passing the values from the first page to the third page at all. You need to add the values you captured from the first page to the query string going to the third page.
Response.Redirect("DisplayPage.aspx?EmailId=" + txtEmailid.Text + "&MobileNo=" + txtMno.Text + "&FirstName" + FirstName + "&LastName" + LastName + "&DateofBirth" + DateofBirth);
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, May 9, 2020 5:27 PM -
User-1996127953 posted
Hi KahyW
thanks for your suggestion now first page value displaying the last page url successfully but I want to print there value on page
I want to print the last page url value:
For ex:
FirstName=Raju
LastName=Patil
DateofBirth=00/00/0000
EmailId=raju@gmail.com
MobileNo=123456789
Sunday, May 10, 2020 4:37 AM -
User409696431 posted
I answered your first question. Please mark it as the answer.
Your second question should be a separate post, is is not related to your first question.
And when you ask it in a new post, please be a lot more clear about what you are asking. I don't understand that question.
Sunday, May 10, 2020 6:31 PM -
User-1996127953 posted
Ok, Thnks for your suggestion
Monday, May 11, 2020 3:57 AM