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. Web Development
  3. ASP.NET
  4. Submit a WebForm

Submit a WebForm

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelp
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.
  • R Offline
    R Offline
    Ritwik Sanyal
    wrote on last edited by
    #1

    Suppose I have two webforms WebForm1 and WebForm2 and now I want to Submit Webform1 to WebForm2 and get the values of form fields of WebForm1 fron WebForm2 using Request.Form method. Please help.:laugh: I am a Software Developer using C# on ASP.NET.

    A 1 Reply Last reply
    0
    • R Ritwik Sanyal

      Suppose I have two webforms WebForm1 and WebForm2 and now I want to Submit Webform1 to WebForm2 and get the values of form fields of WebForm1 fron WebForm2 using Request.Form method. Please help.:laugh: I am a Software Developer using C# on ASP.NET.

      A Offline
      A Offline
      Atilla Ozgur
      wrote on last edited by
      #2

      There are different ways to accomplish this. One is here with querystrings. put this code to your submit button event handler. private void btnSubmit_Click(object sender, System.EventArgs e) { Response.Redirect("Webform2.aspx?Name=" + this.txtName.Text + "&LastName=" + this.txtLastName.Text); } Put this code to second page page_load private void Page_Load(object sender, System.EventArgs e) { this.txtBox1.Text = Request.QueryString["Name"]; this.txtBox2.Text = Request.QueryString["LastName"]; } This way you can get values. Querystring is shown in address bar of your browser therefore you should not use this way to send sensitive information. & is used to distinguish between variables. You can also reach QueryString variables using indexers. foreach( string s in Request.QueryString) { Response.Write(Request.QueryString[s]); Response.Write("///"); } OR for (int i =0;i < Request.QueryString.Count;i++) { Response.Write(Request.QueryString[i]); Response.Write("///"); } I remember reading in somewhere that browsers have some capacity for QueryString length. If you need to send a variable which contains & such as "Mark & Spencer", you have a problem. I have read Server.UrlEncode solves this problem. But below is my solution. private void btnSubmit_Click(object sender, System.EventArgs e) { string p1 = this.txtName.Text.Replace("&","%26"); string p2 = this.txtLastName.Text.Replace("&","%26"); string sln = "WebForm2.aspx?" + "Name=" + p1 + "&LastName=" + p2; Response.Redirect(sln); } Same solution is in Microsoft .Net Quick Start tutorials. ASP.NET--- Working with Web Controls --- Performing Page Navigation (Scenario 1) Performing Page Navigation (Scenario 2) See them also if you want to see more example for this technique. Second solution would be usage of SessionState. Education is no substitute for intelligence. That elusive quality is defined only in part by puzzle-solving ability. It is in the creation of new puzzles reflecting what your senses report that you round out the definition.
      Frank Herbert Education is no substitute for intelligence. That elusive quality is defined only in part by puzzle-solving ability. It is in the creation of new puzzles reflecting what your senses report that you round out the definition. Frank Herbert

      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