Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Garrett Fisher 341 posts 496 karma points
    Jan 25, 2010 @ 20:46
    Garrett Fisher
    0

    multiple forms on same page a problem

    Hi,

    I have noticed that Umbraco comes out of the box, or at least the Creative Website Startr Kit comes out of the box, with a <form> surrounding everything in the Master template.  In the case of the Search form, this And if you remove the form, the applciation breaks.  The problem this presents is multiple forms on one page.  I have my Search form at the top, which is Nested within this outer form, and if there are no other forms on the page, it works fine.  But on the Contact Us page, where I am pulling in an Umbraco Countour form for teh Contact form, when I do a Search, it submits the Contact form instead of the Search form.

    How can I avoid this?  Anyone else had this issue?

    Thanks,

    Garrett

  • Garrett Fisher 341 posts 496 karma points
    Jan 25, 2010 @ 20:50
    Garrett Fisher
    0

    I was not entirely accurate on this post.  It seems that this outer form in the Master template BECOMES whatever form I pull in from a Macro.  So there is always only one form.  But if I want Search AND Contact Us, then I obviously nede two.  How to achieve?

  • Dan 1288 posts 3921 karma points c-trib
    Jan 25, 2010 @ 21:19
    Dan
    0

    The general rule to remember is that you can only have one server-side form (runat=server) on a page, but providing you don't nest your forms you can have as many HTML forms as you like along with this.  So the common way to do what you want is to remove the form with the 'runat=server' from your master template and only include it around the item which requires it (Contour forms in your case I think), then use a standard HTML form for things like your search input box which don't require to run on the server side.

    Hope this helps...

  • Garrett Fisher 341 posts 496 karma points
    Jan 25, 2010 @ 22:04
    Garrett Fisher
    0

    It does, I mean I am getting Somewhere.  I get what you're saying, and I tried this; but according to the error I am getting when loading the Contact Us form page, the Search form cannot be a standard htm,HTML form:

    Control
    'ctl00_ctl00_ctl00_ContentPlaceHolderDefault_SearchBox_3_searchText' of
    type 'TextBox' must be placed inside a form tag with runat=server.

    I now have two forms, neither of which are nested.  BOTH the Search form AND the Contour form are telling me they need to have the runat=server, so I don't know what to Do here.  How can the CWS_Search macro be a standard HTML form?

    Continued thanks,

    Garrett

  • Dan 1288 posts 3921 karma points c-trib
    Jan 25, 2010 @ 23:04
    Dan
    0

    Hi Garrett,

    I've not used that particular search package, but I know for certain that Doug Drobar's XSLTSearch package works from a standard HTML form post/get, so perhaps try that one (I know it's an alternative rather than a solution, but it should work).  I've used XSLTSearch and Contour together on a couple of sites and they live in total harmony :)

  • Garrett Fisher 341 posts 496 karma points
    Jan 25, 2010 @ 23:17
    Garrett Fisher
    0

    Darn it.  Have already done so much work formatting the form and results and all that.  Well, I just tried that XSLTSearch Macro in my template, and yes, it does appear not to cause a conflict; I was just confused by some of the parameters it takes.  For example, what is the "Source" parameter?  Meaning the node below which you would like the search to be performed? 

    Hey-- thanks again.

    //Garrett

  • trfletch 598 posts 604 karma points
    Feb 02, 2010 @ 00:06
    trfletch
    0

    Hi, I too have this problem. I have a custom google map search that is runat=server and I want the end user to be able to put Contour forms in rich text editors on pages. Is there no other way around this? If not, then I may have to ask for a refund on Contour.

  • Garrett Fisher 341 posts 496 karma points
    Feb 03, 2010 @ 17:28
    Garrett Fisher
    0

    Hi Dan,

    I'm now trying to use the XSLT Search macro.  The form shows up fine (input/submit), but instead of results I'm getting a Page Cannot Be Displayed error.  Any idea what I'm doing wrong?

    Form HTML output:

    <form action="?" method="post" class="xsltsearch_form" xmlns:ps="urn:percipientstudios-com:xslt"><input name="search" type="text" class="input" value="" /> <input type="submit" value="Search" class="submit" /></form>

    Macro in template:

    <umbraco:Macro source="1080" searchFields="pageName, text" previewFields="pageName, text" searchBoxLocation="BOTH" previewType="BEGINNING" resultsPerPage="5" previewChars="255" showPageRange="1" showOrdinals="0" showScores="0" showStats="1" Alias="XSLTsearch" runat="server"></umbraco:Macro>

    Thanks,

    Garrett

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Feb 04, 2010 @ 02:36
    Nik Wahlberg
    0

    Garrett,

    may want to look into using jQuery or simple javascript to post any nested forms that you have in your root form (presumably in one of your templates). THis is typically the best approach since we all have to conform to the one form per page issue. If you want some examples, just let us know.

    Thanks,
    Nik 

  • Bas Schouten 135 posts 233 karma points
    Feb 18, 2010 @ 11:28
    Bas Schouten
    0

    Hi Nik,

    I have the same problem when I use Contour. I would like to see some example's if that is possible.

    Maybe you know if it is possible to change the submit in Contour, so I only have to do this once.

    Thanx,

    Bas

     

     

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Feb 22, 2010 @ 11:08
    Tim
    2

    Hiya,

    In .Net 2 and above, you can assign forms and their validation controls to 'groups' to allow you to have multiple groups of controls on one form on a page that don't interfere with each other. So while you have only one form with runat="server" on the page, the grouping allows you to effectively separate the separate groups of form controls into logical sub-forms.

    Unfortunately, Contour doesn't assign it's controls to a validation group (hopefully this will be in a future release), so any contour form on the same page as another form (such as a search) will cause the two forms to fire each other's validation controls.

    To get round this, assign a 'validationgroup' property to the form button controls and validation controls for each of the forms that you are creating. For example:

    <asp:button id="btnTest" runat="server" validationgroup="search" />

    <asp:requiredfieldvalidator id="reqTest" runat="server" validationgroup="search" />

    Clicking the btnTest button would only fire the validation events for the validation controls in the same group as itself, everything else will be ignored, allowing you to have multiple forms within the same asp.net form.

    Hope that makes sense/is useful.

    :)

     

  • aviraj 3 posts 72 karma points
    Dec 16, 2015 @ 16:53
    aviraj
    0

    I'm also facing this nested html form issue. Please let me know if anyone having solution on it.

    My Problem statement:

    I'm working on web application which is developed in Umbraco CMS .Net framework. and I want to add one html form in existing umbraco page. When I add my html form and run the application that time umbraco add one parent form to my form. And when I try to post my form through JavaScript it gives me error "Uncaught TypeError: Cannot read property 'submit' of null".*

    See below code.

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft