Friday, April 23, 2010

How to send values from one aspx page to another aspx page using "post method"

How to send values from one aspx page to another aspx page using "post method"

Create a class named RemotePost.vb
and add the following code in that class

Imports Microsoft.VisualBasic

Public Class RemotePost

    Private Inputs As System.Collections.Specialized.NameValueCollection = New System.Collections.Specialized.NameValueCollection

    Public Url As String = ""
    Public Method As String = "post"
    Public FormName As String = "form1"
    Public Sub Add(ByVal name As String, ByVal value As String)
        Inputs.Add(name, value)
    End Sub
    Public Sub Post()
        System.Web.HttpContext.Current.Response.Write(String.Format("", FormName))

", FormName, Method, Url)) Dim i As Integer = 0 Do While i < Inputs.Keys.Count System.Web.HttpContext.Current.Response.Write(String.Format("", Inputs.Keys(i), Inputs(Inputs.Keys(i)))) i += 1 Loop System.Web.HttpContext.Current.Response.Write("
") System.Web.HttpContext.Current.Response.Write("") System.Web.HttpContext.Current.Response.End() End Sub End Class

now from any page from which u want to pass the value
use the following code

Dim myremotepost As RemotePost = New RemotePost
myremotepost.Url = "targetURL.aspx"
myremotepost.Add("param_name", "param_value")
 for c sharp version mail me

No comments:


Hell0 Friends,
i know you are stuck with some serious problems and that's why you are here. So friends i m putting all the solved problems(with solution) that i have faced in my life (technical problems) on this blog.
In case you can not find the proper solutions, feel free to mail me at
Amit Panchal