0

I need to pass data between pages using ASP.NET C#, I need to get text value from first page to second page inside a TextBox using HttPost. My pages structure is given below I have Two(2) pages as given below:

WebForm1.aspx

<form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtData" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="btnHttpPost" runat="server" Text="HTTPPost" PostBackUrl="~/WebForm2.aspx" />
    </div>
</form>

WebForm2.aspx

<form id="form1" runat="server">
    <div>
        <h1>HttpPost</h1>
        Data is: <%=Request.Form["txtData"] %>
        <p>
            <asp:TextBox ID="txtGetValue" runat="server"></asp:TextBox>
        </p>
    </div>
</form>

As we see in WebForm2.aspx the line below Heading 1 Tag working fine, but I need the value of the previous page (WebForm1.aspx) in TextBox named (txtGetValue) available in second page (Webform2.aspx).

2
  • One line in code behind's Page_Load should do it. Have you tried that? Commented Mar 29, 2017 at 11:14
  • No, Please guide me and type that line. Will be very very thankful Commented Mar 29, 2017 at 11:20

1 Answer 1

1

That can be really easily done in code behind. Like so:

public void Page_Load(object sender, EventArgs e)
{
    txtGatValue.Text = Request.Form["txtData"];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.