why am i not able to pass two values between pages
in first page for submit_btn.click()
Dim url As String
url = "Project.aspx?"
url &= "id=" & id_txt.Text & ""
url &= "age=" & age_txt.Text & ""
Response.Redirect(url)

----------------------------
In second page called Project.aspx:
sub page_load()
txtid.Text = "id:" & Request.QueryString("id")
txtage.Text = "age: " & Request.QueryString("age")
------------------------------
I get output has (Project.aspx?id=35age=)

Dani AI

Generated

Short expert note referencing the thread: the symptom described by (final URL like Project.aspx?id=35age= and no age value) is the classic result of concatenating query parameters without a separator, so the second key never gets parsed. was correct to point toward adding the missing separator, but a few safer patterns and cross-page options are worth showing.

A robust way to build a query string (auto-encodes values and inserts separators) is to use the framework helper that produces a well-formed query collection:

Dim qs = System.Web.HttpUtility.ParseQueryString(String.Empty)
qs("id") = id_txt.Text
qs("age") = age_txt.Text
Response.Redirect("Project.aspx?" & qs.ToString())

This prevents accidental missing ampersands and handles URL-encoding for special characters.

For true cross-page transfer (no query string), either use cross-page posting (Button.PostBackUrl) and PreviousPage, or Server.Transfer with form preservation. A minimal PreviousPage pattern:

If PreviousPage IsNot Nothing Then
  Dim src = TryCast(PreviousPage.FindControl("id_txt"), TextBox)
  If src IsNot Nothing Then txtid.Text = "id: " & src.Text
End If

Notes and troubleshooting: confirm that age_txt.Text actually contains a value before redirecting; inspect the constructed URL (Debug.WriteLine or a temporary Response.Write) to verify the exact string being sent; prefer POST or cross-page posting for non-public data; and URL-encode values when building query strings. The immediate fix in this thread is the missing parameter separator, but the approaches above make the code more robust and easier to debug.

Recommended Answers

All 3 Replies

Try

Dim url As String
url = "Project.aspx?"
url &= "id=" & id_txt.Text & "&"
url &= "age=" & age_txt.Text
Response.Redirect(url)

----------------------------
In second page called Project.aspx try:

sub page_load()
txtid.Text = "id:" & Request("id")
txtage.Text = "age: " & Request("age")

This works for me

hey peter,
thanks for the reply .but still im n2 getting the required answer i dont know why?? im gettin only id value,but not the age value......
regards....
preetham

somebody plz tell m,how to perform cross page transfer.....

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.