I want to retrieve data from controls in the requested page to other page by
using request.form(control name) but this is not working for me.I tried both response.redirect and also server.transfer for redirect to new page but it is not working for both the commands.

Dani AI

Generated

A few practical points that will explain why Request.Form sometimes looks "empty" and how to fix it (addresses the cases raised by , and ).

Request.Form only contains values sent in the HTTP POST body. A client-side redirect (Response.Redirect) issues a new request from the browser and the original POST body is lost. Server.Transfer runs the target page on the server and can keep the original Request, so it is the right tool when you need the posted form values on the next page. Plain HTML inputs will appear in Request.Form only if they actually have a name attribute and are inside the submitting form. Server controls get names from their ID, but dynamic server controls must be recreated on every postback early in the lifecycle (Page_Init) so ASP.NET can bind posted values and ViewState.

Quick troubleshooting checklist

  • Confirm the page is submitted with POST and the submit button is inside the form.
  • Verify each input has a correct name (use browser DevTools -> Network -> Payload to see what was sent).
  • If inputs are created as server controls, recreate them in Page_Init with stable IDs.
  • If you must redirect the browser, use QueryString/Session or submit directly to the target page (cross-page postback/PostBackUrl) instead of Response.Redirect.

Quick debug snippet to see exactly what arrived (VB.NET):

For Each k As String In Request.Form.AllKeys
    Response.Write(k & " = " & Request.Form(k) & "<br/>")
Next

If multiple inputs share the same name, use Request.Form.GetValues(name) to get them all. Context.Items or Session are valid alternatives for transferring server-side data when a client redirect is required.

Here's an example. Lets say you have page1.aspx with a textbox control. You want a user to click a next button, transfering to page2.aspx and writting the text out on that page.

The code for button click on page1.aspx

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        Dim context As HttpContext = HttpContext.Current
        context.Items.Add("strFirstName", TextBox1.Text)
        Server.Transfer("page2.aspx", True)
    End Sub

The page_load for the page2.aspx:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Dim context As HttpContext = HttpContext.Current
        Response.Write("Your First Name is: " & context.Items("strFirstName"))
    End Sub

-sypher

thank you for your reply sypher.

ramareddy_dotne

I am having the same problem with a slight difference. I hope someone can help.
In my aspx page I have the following:

<script>
  sub blah()
   For intloop = 0 To (intFieldCount - 1)
    Dim oCell As New TableCell()
    strDateLink = "<input name='" & strInputName & "' type='text' value='" & dtClosureDate.ToLongDateString & "' size='33' rows='1' class='ltk' style='border:none'  />"
    oCell.Text = strDateLink
    oRow.Cells.Add(oCell)
Next
  end sub
  </script>

A you can see I am building <input> dynamically. Let’s say that the above loops 20 times, each with a different name for the dynamic <input>. How can I transfer these 20 values?
I have the following control in the body of the page.

<asp:Button id="btnPreCloseSumbit" OnClick="TransferFormValues" Text="Submit " runat="server"/>

Which calls

Sub TransferFormValues(Source As Object, E As EventArgs)
    Dim context As HttpContext = HttpContext.Current
    context.Items.Add("strFirstName", TextBox1.Text)
    Server.Transfer("body_date_closures_test_output.aspx", True)
 End Sub

I guess I don’t understand how to transfer the form input that has a dynamic name.

Sub Page_Load(Source As Object, E As EventArgs)
    response.Write("hello<br><br>")
    Dim context As HttpContext = HttpContext.Current
    Response.Write(context.Items("strFirstName"))
    response.Write("<br><br>...")
End Sub

-nbp

it's okay. i just relised that i had been going about this the wrong way. i am able to use the request.form("id") instead of redirect and request.

-np.

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.