Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Post a html fields to a specific url?????????

Post a html fields to a specific url?????????

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharphtmltutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nithin Krishna
    wrote on last edited by
    #1

    Hi friends, Can anyone advice me how to post some html fields to a specific url (https) using .net and c#. Thanks and Rgds Nithin

    S 1 Reply Last reply
    0
    • N Nithin Krishna

      Hi friends, Can anyone advice me how to post some html fields to a specific url (https) using .net and c#. Thanks and Rgds Nithin

      S Offline
      S Offline
      SHatchard
      wrote on last edited by
      #2

      You could firstly just sent the action of the form to the destination, which would be the easiest way. However, a while back I wrote a simple class which would allow you to post to a Url from code which is included below in case you find it useful Public Class Poster #Region " Properties " Private values As New System.Collections.Specialized.NameValueCollection Private _postUrl As String Public Property PostUrl() As String Get Return _postUrl End Get Set(ByVal value As String) _postUrl = value End Set End Property Private _formName As String = "form1" Public Property FormName() As String Get Return _formName End Get Set(ByVal value As String) _formName = value End Set End Property Private _method As String = "POST" Public Property Method() As String Get Return _method End Get Set(ByVal value As String) _method = value End Set End Property Public Sub AddValue(ByVal name As String, ByVal value As String) values.Add(name, value) End Sub #End Region #Region " Publish Methods " Public Sub Post() If PostUrl Is Nothing Then Throw New Exception("No Url specified") If FormName Is Nothing Then Throw New Exception("No Form Name specified") If String.IsNullOrEmpty(Method) Then Throw New Exception("No method specified") 'if values.Count=0 then throw new Exception("No post values supplied") HttpContext.Current.Response.Clear() HttpContext.Current.Response.Write("") HttpContext.Current.Response.Write(String.Format("", FormName)) HttpContext.Current.Response.Write(String.Format(" ", FormName, Method, PostUrl)) For i As Integer = 0 To values.Count - 1 System.Web.HttpContext.Current.Response.Write(String.Format("", values.Keys(i), values(values.Keys(i)))) Next HttpContext.Current.Response.Write(" ") HttpContext.Current.Response.Write("") HttpContext.Current.Response.End() End Sub #End Region End Class

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups