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. Programatically change form action value?

Programatically change form action value?

Scheduled Pinned Locked Moved ASP.NET
tutorialhtmlquestion
4 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.
  • D Offline
    D Offline
    davebarkshire
    wrote on last edited by
    #1

    Can anyone tell me how to programatically change the html form action value? For example, my page has this form.

    I want to change the action value. I have tried this... HtmlForm objForm = (HtmlForm)Page.Controls[1]; which gets me a handle for the form, but I can see no value that will allow me to change the action. Thanks in advance - Dave.

    M 1 Reply Last reply
    0
    • D davebarkshire

      Can anyone tell me how to programatically change the html form action value? For example, my page has this form.

      I want to change the action value. I have tried this... HtmlForm objForm = (HtmlForm)Page.Controls[1]; which gets me a handle for the form, but I can see no value that will allow me to change the action. Thanks in advance - Dave.

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi Dave, Even you use the HtmlForm.Attributes property to add the action value, it'll still be removed in the RenderAttributes method. There are a couple of options here, you can use the client side code to change the action value of the form element by creating an event handler for the onload event of the body element. Or you can create your own custom html form control by overriding the RenderAttributes method, there's an example posted here on CP http://www.codeproject.com/aspnet/CHtmlForm.asp[^]. However, you also need to consider the ViewState issue when submit the page to another one.

      D 1 Reply Last reply
      0
      • M minhpc_bk

        Hi Dave, Even you use the HtmlForm.Attributes property to add the action value, it'll still be removed in the RenderAttributes method. There are a couple of options here, you can use the client side code to change the action value of the form element by creating an event handler for the onload event of the body element. Or you can create your own custom html form control by overriding the RenderAttributes method, there's an example posted here on CP http://www.codeproject.com/aspnet/CHtmlForm.asp[^]. However, you also need to consider the ViewState issue when submit the page to another one.

        D Offline
        D Offline
        davebarkshire
        wrote on last edited by
        #3

        Thanks for that valuable information. I would never have guessed! I've been wrestling with dot net for the last 8 months (many hours every day) and I still have to fight it every inch of the way unless I want to do 'hello world' level programs. I sometimes spend weeks doing what I could have done in VS6 in hours! I do like VS7 but find it very complicated still and hope that I don't starve to death before that time comes. (Are you listening Mr Gates???):((

        M 1 Reply Last reply
        0
        • D davebarkshire

          Thanks for that valuable information. I would never have guessed! I've been wrestling with dot net for the last 8 months (many hours every day) and I still have to fight it every inch of the way unless I want to do 'hello world' level programs. I sometimes spend weeks doing what I could have done in VS6 in hours! I do like VS7 but find it very complicated still and hope that I don't starve to death before that time comes. (Are you listening Mr Gates???):((

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          davebarkshire wrote: (Are you listening Mr Gates???) Gates: "Yes, I am. And I know that CP surely can help you fight with your difficulties". I saw him saying that in my dream last night. ;P

          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