|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Querystring -> Codebehind?
<i><b>Originally posted by : Bret (bret.vanhorn@tripleteam.com)</b></i><br />Okay, this is probably a silly question, but I'm new to .NET/VB and haven't been able to find an answer to this anywhere. <br /><br />I want to send a variable from an ASPX page querystring/GET form submission and have the codebehind for that page access that variable on postback, preferably without a server control. <br /><br />Classic ASP has that handy request.querystring("foo") method of accessing such variables, but I can't see a way to access that from the codebehind, even if I update the syntax to request.querystring("foo")(0).<br /><br />If anyone has any ideas, I'd gladly give you millions of dollars to ease my suffering mind -- only I don't have a million dollars. So my undying gratitude will have to suffice.<br /><br />Thanks in advance,<br /><br />-Bret<br /><br />
|
|
#2
|
|||
|
|||
|
<i><b>Originally posted by : Julia Lerman (jlerman@thedatafarm.com)</b></i><br />Bret-<br />I struggled with this one for a while a few weeks ago! The secret is that you have to shove the query string into a special type of collection and then pull out its elements. You can use this code to then go examine the SDK for more information.<br /><br />This code is in VB.Net.<br /><br />I am grabbing the elements and putting them into pre-defined variables and textboxes.<br /><br />Here is sample code of how I accomplished it:<br />The "Request" in my first line refers to the calling form.<br /><br /> Dim oRequest As HttpRequest = Request<br /> Dim arr2 As String<br /> Dim coll As Specialized.NameValueCollection<br /> coll = Request.QueryString<br /> If coll.Count > 1 Then '1 is the submit button<br /> arr2 = CStr(coll.GetValues("id")(0))<br /> If arr2 <> vbNullString Then<br /> m_iBooksid = CStr(coll.GetValues("id")(0))<br /> txtBookTitle.Value = CStr(coll.GetValues("booktitle")(0))<br /> txtAuthor.Value = CStr(coll.GetValues("author")(0))<br /> txtPublisher.Value = CStr(coll.GetValues("pub")(0))<br /> End If<br /> End If<br /><br />Julia Lerman<br />VTdotNet User Group Coordinator<br />www.thedatafarm.com/vtdotnet<br /><br /><br />------------<br />Bret at 5/13/2002 11:20:42 AM<br /><br />Okay, this is probably a silly question, but I'm new to .NET/VB and haven't been able to find an answer to this anywhere. <br /><br />I want to send a variable from an ASPX page querystring/GET form submission and have the codebehind for that page access that variable on postback, preferably without a server control. <br /><br />Classic ASP has that handy request.querystring("foo") method of accessing such variables, but I can't see a way to access that from the codebehind, even if I update the syntax to request.querystring("foo")(0).<br /><br />If anyone has any ideas, I'd gladly give you millions of dollars to ease my suffering mind -- only I don't have a million dollars. So my undying gratitude will have to suffice.<br /><br />Thanks in advance,<br /><br />-Bret<br /><br />
|
|
#3
|
|||
|
|||
|
<i><b>Originally posted by : nybble_me (nybble_me@hotmail.com)</b></i><br />Request.QueryString["FOO"]<br /><br />Use [] instead of (), at least that's how it works in the C# world.<br /><br /><br />------------<br />Julia Lerman at 5/20/2002 9:42:42 AM<br /><br />Bret-<br />I struggled with this one for a while a few weeks ago! The secret is that you have to shove the query string into a special type of collection and then pull out its elements. You can use this code to then go examine the SDK for more information.<br /><br />This code is in VB.Net.<br /><br />I am grabbing the elements and putting them into pre-defined variables and textboxes.<br /><br />Here is sample code of how I accomplished it:<br />The "Request" in my first line refers to the calling form.<br /><br /> Dim oRequest As HttpRequest = Request<br /> Dim arr2 As String<br /> Dim coll As Specialized.NameValueCollection<br /> coll = Request.QueryString<br /> If coll.Count > 1 Then '1 is the submit button<br /> arr2 = CStr(coll.GetValues("id")(0))<br /> If arr2 <> vbNullString Then<br /> m_iBooksid = CStr(coll.GetValues("id")(0))<br /> txtBookTitle.Value = CStr(coll.GetValues("booktitle")(0))<br /> txtAuthor.Value = CStr(coll.GetValues("author")(0))<br /> txtPublisher.Value = CStr(coll.GetValues("pub")(0))<br /> End If<br /> End If<br /><br />Julia Lerman<br />VTdotNet User Group Coordinator<br />www.thedatafarm.com/vtdotnet<br /><br /><br />------------<br />Bret at 5/13/2002 11:20:42 AM<br /><br />Okay, this is probably a silly question, but I'm new to .NET/VB and haven't been able to find an answer to this anywhere. <br /><br />I want to send a variable from an ASPX page querystring/GET form submission and have the codebehind for that page access that variable on postback, preferably without a server control. <br /><br />Classic ASP has that handy request.querystring("foo") method of accessing such variables, but I can't see a way to access that from the codebehind, even if I update the syntax to request.querystring("foo")(0).<br /><br />If anyone has any ideas, I'd gladly give you millions of dollars to ease my suffering mind -- only I don't have a million dollars. So my undying gratitude will have to suffice.<br /><br />Thanks in advance,<br /><br />-Bret<br /><br />
|
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > Querystring -> Codebehind? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|