Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Deane - 30 Jul 2007 20:46 GMT
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?
Steve C. Orr [MCSD, MVP, CSM, ASP Insider] - 30 Jul 2007 22:07 GMT
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.

Signature

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

> I've run into this problem on many occasions --
>
[quoted text clipped - 11 lines]
> you get a "traditional" (non server-side) HTML form to work within the
> server-side form tag?
Brandon Gano - 30 Jul 2007 22:10 GMT
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.

> I've run into this problem on many occasions --
>
[quoted text clipped - 11 lines]
> you get a "traditional" (non server-side) HTML form to work within the
> server-side form tag?
Deane - 01 Aug 2007 15:33 GMT
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?

> 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
[quoted text clipped - 59 lines]
> > you get a "traditional" (non server-side) HTMLformto work within the
> > server-sideformtag?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.