Dobrý den, chci po své aplikaci, aby poslala data z proměných na jistou stránku, vyplnila formulář a odeslala ho. Zatím jsem to řešil takto:
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.Clear()
System.Web.HttpContext.Current.Response.Write("<html><head>")
System.Web.HttpContext.Current.Response.Write(String.Format("</head><body onload=""document.{0}.submit()"">", FormName))
System.Web.HttpContext.Current.Response.Write(String.Format("<form name=""{0}"" method=""{1}"" action=""{2}"" >", FormName, Method, Url))
Dim i As Integer = 0
Do While i < Inputs.Keys.Count
System.Web.HttpContext.Current.Response.Write(String.Format("<input name=""{0}"" type=""hidden"" value=""{1}"">", Inputs.Keys(i), Inputs(Inputs.Keys(i))))
i += 1
Loop
System.Web.HttpContext.Current.Response.Write("</form>")
System.Web.HttpContext.Current.Response.Write("</body></html>")
System.Web.HttpContext.Current.Response.End()
End Sub
End Class
Protected Sub FileFlightPlanButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim myremotepost As RemotePost = New RemotePost
myremotepost.Url = "http://www.vatsim.net/fp/index.php"
myremotepost.Add("1", "I")
myremotepost.Add("2", CALLSIGNGetLabel.Text)
myremotepost.Add("3", aircrafticaogetlabel.Text)
myremotepost.Add("4", SpeedGetLabel.Text)
myremotepost.Add("5", DepartureAirportGetLabel.Text)
myremotepost.Add("6", DeparturetimeGetLabel.Text)
myremotepost.Add("7", AltitudeGetLabel.Text)
myremotepost.Add("8", RouteGetLabel.Text)
myremotepost.Add("9", ArrivalAirportGetLabel.Text)
myremotepost.Add("10a", Enroute1GetLabel.Text)
myremotepost.Add("10b", Enroute2GetLabel.Text)
myremotepost.Add("voice", "/V/")
myremotepost.Add("11", RemarksGetLabel.Text)
myremotepost.Add("12a", Endurance1GetLabel.Text)
myremotepost.Add("12b", Endurance2GetLabel.Text)
myremotepost.Add("13", AlternateAirportGetLabel.Text)
myremotepost.Add("14", VatsimnamegetLabel.Text)
myremotepost.Add("15", vatsimidgetLabel.Text)
myremotepost.Add("16", vatsimpasswordgetLabel.Text)
myremotepost.Post()
End Sub
Problém je, že ale nechci být přesměrován na danou adresu, ale chci, aby to aplikace provedla na pozadí a přesměrovala mě tam, kam já chci. Předem děkuji za odpovědi. Tomáš Jareš
|