Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Getting a "normal" HTML form to work inside the server-side form tag

Reply
Thread Tools

Getting a "normal" HTML form to work inside the server-side form tag

 
 
Deane
Guest
Posts: n/a
 
      07-30-2007
I've run into this problem on many occasions --

I need to have the server side form tag on my Web form, of course.

But I also need to have *another* form on the page that posts to a URL
totally out of my control. I can think of three situations off the
top of my head.

In one case, it was a login to the client's PeopleSoft system.
In another, it was a PayPal form.
In another, the form posted to the client's Google Mini install.

What's the solution for this? I haven't found a good one yet. How do
you get a "traditional" (non server-side) HTML form to work within the
server-side form tag?

 
Reply With Quote
 
 
 
 
Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
Guest
Posts: n/a
 
      07-30-2007
A form cannot be within another form. This is against the rules of HTML.
You can have more than one form as long as one of them is a "traditional"
(non server-side) HTML form as you've specified. Just don't nest them.
Make sure there is no runat="server" attribute for your traditional HTML
form.

--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net




"Deane" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> I've run into this problem on many occasions --
>
> I need to have the server side form tag on my Web form, of course.
>
> But I also need to have *another* form on the page that posts to a URL
> totally out of my control. I can think of three situations off the
> top of my head.
>
> In one case, it was a login to the client's PeopleSoft system.
> In another, it was a PayPal form.
> In another, the form posted to the client's Google Mini install.
>
> What's the solution for this? I haven't found a good one yet. How do
> you get a "traditional" (non server-side) HTML form to work within the
> server-side form tag?
>


 
Reply With Quote
 
 
 
 
Brandon Gano
Guest
Posts: n/a
 
      07-30-2007
Forms cannot be nested, so there is no way to have a client-side form inside
a server-side form. There are a couple other options that might work for
you, though.

1) Don't nest the forms. Only server-side controls need to be contained
within a <form runat="server" /> tag. If all of your server-side controls
are above or below the client-side form, you can do something like:

<html>
<body>
<form runat="server">
...
</form>
<form action="...">
...
</form>
</body>
</html>

2) The other option requires the use of JavaScript to change the forms
action when you click a link/button. Something like (not tested):

<html>
<head>
<script type="text/javascript">
function SubmitForm()
{
var form = document.getElementById('MyForm');
if (form)
{
form.action = 'new/url';
form.submit();
}
}
</script>
</head>
<body>
<form runat="server">
...
<input type="submit" value="Click" onclick="JavaScript: SubmitForm();" />
</form>
</body>
</html>

3) There is also a way to set the server-side form to post back to a
different URL. I don't recall the syntax to do that, but I'm sure someone
else in the group can help there.


"Deane" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> I've run into this problem on many occasions --
>
> I need to have the server side form tag on my Web form, of course.
>
> But I also need to have *another* form on the page that posts to a URL
> totally out of my control. I can think of three situations off the
> top of my head.
>
> In one case, it was a login to the client's PeopleSoft system.
> In another, it was a PayPal form.
> In another, the form posted to the client's Google Mini install.
>
> What's the solution for this? I haven't found a good one yet. How do
> you get a "traditional" (non server-side) HTML form to work within the
> server-side form tag?
>


 
Reply With Quote
 
Deane
Guest
Posts: n/a
 
      08-01-2007
Sadly, it appears that I'm thoroughly screwed here.

I have server-side controls both above and below where this other HTML
form needs to go. So the whole thing needs to go in a server-side
form tag. And you can't have more than one server-side form tag, so
it's not like I can "shut it off," do the normal form, then turn it
back on again.

Ideas?



On Jul 30, 4:10 pm, "Brandon Gano" <(E-Mail Removed)> wrote:
> Forms cannot be nested, so there is no way to have a client-sideforminside
> a server-sideform. There are a couple other options that might work for
> you, though.
>
> 1) Don't nest the forms. Only server-side controls need to be contained
> within a <formrunat="server" /> tag. If all of your server-side controls
> are above or below the client-sideform, you can do something like:
>
> <html>
> <body>
> <formrunat="server">
> ...
> </form>
> <formaction="...">
> ...
> </form>
> </body>
> </html>
>
> 2) The other option requires the use of JavaScript to change the forms
> action when you click a link/button. Something like (not tested):
>
> <html>
> <head>
> <script type="text/javascript">
> function SubmitForm()
> {
> varform= document.getElementById('MyForm');
> if (form)
> {
> form.action = 'new/url';
> form.submit();
> }
> }
> </script>
> </head>
> <body>
> <formrunat="server">
> ...
> <input type="submit" value="Click" onclick="JavaScript: SubmitForm();" />
> </form>
> </body>
> </html>
>
> 3) There is also a way to set the server-sideformto post back to a
> different URL. I don't recall the syntax to do that, but I'm sure someone
> else in the group can help there.
>
> "Deane" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) ups.com...
>
> > I've run into this problem on many occasions --

>
> > I need to have the server sideformtag on my Webform, of course.

>
> > But I also need to have *another*formon the page that posts to a URL
> > totally out of my control. I can think of three situations off the
> > top of my head.

>
> > In one case, it was a login to the client's PeopleSoft system.
> > In another, it was a PayPalform.
> > In another, theformposted to the client's Google Mini install.

>
> > What's the solution for this? I haven't found a good one yet. How do
> > you get a "traditional" (non server-side) HTMLformto work within the
> > server-sideformtag?



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting text inside the HTML tag Nikola Skoric Python 5 07-17-2007 05:40 AM
HTML.Tag.BASE same as HTML.Tag.A carlbernardi@gmail.com Java 1 11-29-2006 03:41 AM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
How Can I put XSL tag inside HTML form tag? RC Java 2 05-10-2005 06:26 PM
How Can I put XSL tag inside HTML form tag? RC XML 2 05-10-2005 05:55 PM



Advertisments