Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Is there any way to do a post to another page in the code behind?

Reply
Thread Tools

Is there any way to do a post to another page in the code behind?

 
 
mortb
Guest
Posts: n/a
 
      11-10-2004
Sometimes you want to transfer to another page and pass some values along
not using the query string nor the session.
Is there some way to do this?

cheers,
mortb


 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      11-10-2004
You can do a post using the WebClient class. Here's some sample code. The
values to post go in the NameValueCollection

Sub DoPost()
Dim uriString As String = _
"http://localhost/p4320work/mySpecialPage.aspx"
Dim strGoName As String
strGoName = TextBox1.Text
' Create a new WebClient instance.
Dim myWebClient As New System.Net.WebClient
Dim myNameValueCollection As New _
System.Collections.Specialized.NameValueCollection
myNameValueCollection.Add("go1", strGoName)
myNameValueCollection.Add("Button1", "")
Dim responseArray As Byte() = myWebClient.UploadValues _
(uriString, "POST", myNameValueCollection)

Label1.Text = "Response received was :" & _
System.Text.Encoding.ASCII.GetString(responseArray )
End Sub

Ken
Microsoft MVP [ASP.NET]
Toronto

"mortb" <mortb1<noospam<@hotmail.com> wrote in message
news:%23Y%...
> Sometimes you want to transfer to another page and pass some values along
> not using the query string nor the session.
> Is there some way to do this?
>
> cheers,
> mortb
>


 
Reply With Quote
 
 
 
 
mortb
Guest
Posts: n/a
 
      11-10-2004
Is it not possible to go directly to the page like response.redirect but
using a post instead?
As if the form would post to another page?

/mortb

"Ken Cox [Microsoft MVP]" <> wrote in message
news:%...
> You can do a post using the WebClient class. Here's some sample code. The
> values to post go in the NameValueCollection
>
> Sub DoPost()
> Dim uriString As String = _
> "http://localhost/p4320work/mySpecialPage.aspx"
> Dim strGoName As String
> strGoName = TextBox1.Text
> ' Create a new WebClient instance.
> Dim myWebClient As New System.Net.WebClient
> Dim myNameValueCollection As New _
> System.Collections.Specialized.NameValueCollection
> myNameValueCollection.Add("go1", strGoName)
> myNameValueCollection.Add("Button1", "")
> Dim responseArray As Byte() = myWebClient.UploadValues _
> (uriString, "POST", myNameValueCollection)
>
> Label1.Text = "Response received was :" & _
> System.Text.Encoding.ASCII.GetString(responseArray )
> End Sub
>
> Ken
> Microsoft MVP [ASP.NET]
> Toronto
>
> "mortb" <mortb1<noospam<@hotmail.com> wrote in message
> news:%23Y%...
>> Sometimes you want to transfer to another page and pass some values along
>> not using the query string nor the session.
>> Is there some way to do this?
>>
>> cheers,
>> mortb
>>

>



 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      11-10-2004
You can :
- alter the action attribute of the form tag using JavaScript
- on google you'll find form controls adding the explicit handling of the
form attribute
- the next release also adds support for this

You could use also Server.Transfer (if you don't need the browser to see the
final URL)

Patrice

--

"mortb" <mortb1<noospam<@hotmail.com> a écrit dans le message de
news:uHUJY$...
> Is it not possible to go directly to the page like response.redirect but
> using a post instead?
> As if the form would post to another page?
>
> /mortb
>
> "Ken Cox [Microsoft MVP]" <> wrote in message
> news:%...
> > You can do a post using the WebClient class. Here's some sample code.

The
> > values to post go in the NameValueCollection
> >
> > Sub DoPost()
> > Dim uriString As String = _
> > "http://localhost/p4320work/mySpecialPage.aspx"
> > Dim strGoName As String
> > strGoName = TextBox1.Text
> > ' Create a new WebClient instance.
> > Dim myWebClient As New System.Net.WebClient
> > Dim myNameValueCollection As New _
> > System.Collections.Specialized.NameValueCollection
> > myNameValueCollection.Add("go1", strGoName)
> > myNameValueCollection.Add("Button1", "")
> > Dim responseArray As Byte() = myWebClient.UploadValues _
> > (uriString, "POST", myNameValueCollection)
> >
> > Label1.Text = "Response received was :" & _
> > System.Text.Encoding.ASCII.GetString(responseArray )
> > End Sub
> >
> > Ken
> > Microsoft MVP [ASP.NET]
> > Toronto
> >
> > "mortb" <mortb1<noospam<@hotmail.com> wrote in message
> > news:%23Y%...
> >> Sometimes you want to transfer to another page and pass some values

along
> >> not using the query string nor the session.
> >> Is there some way to do this?
> >>
> >> cheers,
> >> mortb
> >>

> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any way to refer to another array in qsort's compare function? Stone C Programming 23 01-17-2012 10:35 AM
Is there any way to use a field validator to check if one value is less than another? Mufasa ASP .Net 3 08-13-2007 12:25 PM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
when posting page is there a way to make it post without waiting? Steven Scaife ASP General 2 08-19-2004 01:43 PM
is there a way ..... any way Andries Perl Misc 27 04-27-2004 06:15 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57