[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How can i put a form tag with action = "post" within form tag with runat="server" -Does not work

Posted on 2009-07-15
7
Medium Priority
?
484 Views
Last Modified: 2013-11-26
Hi,

I have an asp.net 2.0 page (C#), and wihtin this page i have to put a form with a submit button that will open a new window and send some data there with hidden fields. Simplified, the HTML looks like this.
But it doesn't work, the site mentioned in form2 action is never openend. It does work when put form2 after the closing tag of form1, but this is not an option as the part of form2 is integrated in the much more complicated page.

Any idea what i can do to make this work?

Thanks,

Dready


<body>
    <form id="Form1" runat="server">
    <table><tr><td>
        <form id="form2" name="form2" method="post" action="https://www.somesite.com/validation.php"
            target="_blank">
            <input type="hidden" name="_charset_" />
            <input name="cust_id" type="hidden" value="X8DCC048644441C1B9A244440D8357AC818D" />
            <input type="submit" id="btnGo" name="btnGo" value="test" />
        </form>
     </td></tr></table>
    </form>
</body>

Open in new window

0
Comment
Question by:dready
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 1

Expert Comment

by:MickelAndersson
ID: 24858139
ASP.Net only allow one form-tag per page.

You will therefore have to find another solution to post to an existing .php-page.


Hope it helps!
0
 
LVL 12

Expert Comment

by:GuitarRich
ID: 24858246
Not quite right - asp.net only allows one runat="server" form on the page.
If your form doesn't require any asp.net controls inside it - try moving the form you want to post outside the server side asp.net form tags like this. You don't have to put all your code inside the generated form element - only the asp.net controls need to go there.

<body>
    <form id="Form1" runat="server">
    </form>
    <table><tr><td>
        <form id="form2" name="form2" method="post" action="https://www.somesite.com/validation.php"
            target="_blank">
            <input type="hidden" name="_charset_" />
            <input name="cust_id" type="hidden" value="X8DCC048644441C1B9A244440D8357AC818D" />
            <input type="submit" id="btnGo" name="btnGo" value="test" />
        </form>
     </td></tr></table>
</body>

Open in new window

0
 
LVL 11

Author Comment

by:dready
ID: 24858483
Hi,

Thanks for your replies.
@GuitarRich: I know, i tried that for the simple example i posted here, and that works. Unfortunately, in the real page, there are ASP.net controls AND asp.net UserControls all around the place where i have to put this...

Does this mean it's not possible to use the form method="post"? Or is there another way to get the same behaviour, f.e. in do something in the code behind onclick handler for the button? I just wouldnt know how to use the input type="hidden" fields in that case .

Any more ideas?

0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
LVL 12

Expert Comment

by:GuitarRich
ID: 24859173
Does that form have asp.net controls in it? You could stick the html for the form outside the server side form and then use CSS to position it on the page?
0
 
LVL 12

Accepted Solution

by:
GuitarRich earned 2000 total points
ID: 24859189
There are also some idea's on how to make nested forms work here http://www.cubiczone.com/Articles/tabid/65/EntryID/21/Default.aspx
0
 
LVL 12

Expert Comment

by:GuitarRich
ID: 24859205
one more idea - would using javascript to sumit your form work? http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml
0
 
LVL 11

Author Closing Comment

by:dready
ID: 31603885
Hey Guitarrich,

Thanks so much for all your suggestions. I first thought about using the iframe solution, but i also have to dynamically set some values in my gadget. But in the end setting the form action dynamically in the click handler (onclick="this.form.action='somesite.com' ) works best and easiest. Only for people without Javascript it wont, but thats ok with me...

Thanks, points well deserved.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question