This situation seems to be all over the place & I'm seeing mixed results for various code configurations in this forum and a lot of others, so I decided to post a topic for my specific scenario to see what the possible solutions might be:
1. I'm using the Runway DropdownNavigation control
2. I'm using Umbraco Contour
3. I also have a search form that needs to post to /search.aspx (from XSLT Search)
If I put a form runat=server tag around the master page, the DropdownNavigation control and the Umbraco Contour Form function fine, but the Search Form doesn't do anything because it is posting back to the page hosting the forms (/default.aspx for example). If I try to put individual form runat=server tags around the DropdownNav and the container that holds Contour, I get the "you can only have one server side form per page" error that seems to plague plenty of other folks.
If I try to alter the search form to be an ASP.NET controlled form in efforts to get PostBackUrl to submit my text box to /search.aspx - like so:
<!-- content place holder from the default master page from Umbraco --> <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Title :)</title> </head> <body> <!-- outer container --> <div id="outer"> <!-- top container --> <div id="top"> </div> <!-- mid container containing 2 forms, one .net and one regular html --> <div id="mid"> <!-- .net form --> <form id="frm" runat="server"> <!-- content container --> <div class="content"> <asp:ScriptManager ID="sm" runat="server"></asp:ScriptManager> <asp:ContentPlaceHolder ID="cphContent" runat="server"></asp:ContentPlaceHolder> </div> </form> <!-- search box with html form (should be outside the .net form tag) --> <div class="search"> <!-- the search will automatically post when you hit enter! --> <!-- postbackurl /search.aspx (whatever you want it to be) --> <form action="/search.aspx" method="post"> <input type="text" id="search" name="search" /> <input type="submit" id="submitSearch" name="submitSearch" value="Search" /> </form> </div> </div> <!-- bottom container --> <div id="Bottom"> </div> </div> </body> </html> </asp:Content>
Actually it is all in the css because as the search box is not important for the user or the developer to be .net (at least for now) well then it does not need to be included in a .net form (which means that it does not need an runat="server" attribute).
As you can put your search box where ever you want to with css and just accommodate the other elements on your page to fit your needs then it does not have to be inside a .net form tag - which makes the solution much more solid.
Two forms, now clashes between nothing at all. If you have any probs feel free to ask...
Just remember at all times that the search box can be placed wherever you want it to be placed with css. I do it all the time and it is so easy if you understand this concept.
But; it's not doing anything. It's a shame - I had high hopes.It does, however, trigger the "required fields" in my Umbraco Contour form, and renders it non-functional; same type issue I was having before. Though I'm not a huge fan of butchering forms around ASP.NET via CSS, I may just lean on Scott's work-around until I can find the fix.
When it's possible use solution which Scott describe: another form without runat="server" outside main form. But it isn't always an option (when you want use canvas for example), then use redirect solution.
@Scott: Sorry for inaccuracy, multiple forms solution works fine with canvas, but controls which can be editable using canvas should be in runat server form, and implemented design sometimes do not allow to have search outside of main form.
The ASP.NET <form runat="server" /> concept is Very Confusing and I'm sue that it leads to much wasted time. It certainly has for me as a newcomer to ASP.NET who has just wasted 2+days and still not happy.
@scott Thank you for this "workaround" which has moved my project forwards, although I am internally convinced that there must be a better solution. What would a professional ASP.NET programmer do? Meanwhile... RE:"..Just remember at all times that the search box can be placed wherever you want it to be placed with css. I do it all the time and it is so easy if you understand this concept..."
I have been unable to find a combination of CSS that works to reposition the search form to be stable at the top of my page such that it repositions correctly when the page is resized. I'm currently using:
Multiple Form Problem
This situation seems to be all over the place & I'm seeing mixed results for various code configurations in this forum and a lot of others, so I decided to post a topic for my specific scenario to see what the possible solutions might be:
1. I'm using the Runway DropdownNavigation control
2. I'm using Umbraco Contour
3. I also have a search form that needs to post to /search.aspx (from XSLT Search)
If I put a form runat=server tag around the master page, the DropdownNavigation control and the Umbraco Contour Form function fine, but the Search Form doesn't do anything because it is posting back to the page hosting the forms (/default.aspx for example). If I try to put individual form runat=server tags around the DropdownNav and the container that holds Contour, I get the "you can only have one server side form per page" error that seems to plague plenty of other folks.
If I try to alter the search form to be an ASP.NET controlled form in efforts to get PostBackUrl to submit my text box to /search.aspx - like so:
It simply doesn't do anything, and also renders the Umbraco Contour form useless; while the DropdownNavigation control still works fine...
Insights?
You can catch submitSearch onclick event and simply do response.redirect to url for search similar to this
Response.Redirect("/search.aspx?search=" + search.Text);
Petr
Yep that does seem like a common problem, however look what I did and it really works like a charm!
Actually it is all in the css because as the search box is not important for the user or the developer to be .net (at least for now) well then it does not need to be included in a .net form (which means that it does not need an runat="server" attribute).
As you can put your search box where ever you want to with css and just accommodate the other elements on your page to fit your needs then it does not have to be inside a .net form tag - which makes the solution much more solid.
Two forms, now clashes between nothing at all. If you have any probs feel free to ask...
Just remember at all times that the search box can be placed wherever you want it to be placed with css. I do it all the time and it is so easy if you understand this concept.
Scott
Petr -
I added:
And have
But; it's not doing anything. It's a shame - I had high hopes.It does, however, trigger the "required fields" in my Umbraco Contour form, and renders it non-functional; same type issue I was having before. Though I'm not a huge fan of butchering forms around ASP.NET via CSS, I may just lean on Scott's work-around until I can find the fix.
If I remember it - I'll post it.
Try
Hey Enrique,
I think that the solutiong I provided before is the most solid and it works flawless, there are other solutions around which puts and empty
However it did not work for me, and the other solution provided has been working very good and it does excactly what I want it to do.
Scott
When it's possible use solution which Scott describe: another form without runat="server" outside main form. But it isn't always an option (when you want use canvas for example), then use redirect solution.
Petr, can you dig a little deeper into why it won't work with canvas? (I honestly haven't tested it myself with canvas).
Scott
@Scott: Sorry for inaccuracy, multiple forms solution works fine with canvas, but controls which can be editable using canvas should be in runat server form, and implemented design sometimes do not allow to have search outside of main form.
@Petr: Ah okay, now I understand, thank you for clearing that up.
The ASP.NET <form runat="server" /> concept is Very Confusing and I'm sue that it leads to much wasted time. It certainly has for me as a newcomer to ASP.NET who has just wasted 2+days and still not happy.
@scott Thank you for this "workaround" which has moved my project forwards, although I am internally convinced that there must be a better solution. What would a professional ASP.NET programmer do? Meanwhile...
RE:"..Just remember at all times that the search box can be placed wherever you want it to be placed with css. I do it all the time and it is so easy if you understand this concept..."
I have been unable to find a combination of CSS that works to reposition the search form to be stable at the top of my page such that it repositions correctly when the page is resized. I'm currently using:
#search_form {
position: absolute;
top: 3px;
left: 940px;
}
Suggestions welcome!
John P
is working on a reply...