Last post Aug 18, 2007 11:26 AM by Sojan80
Mar 09, 2007 01:08 PM|Sojan80|LINK
I'm just getting started with ASP.NET 2.0 and one of the things I noticed is that a web form is well, just that, a form. So, I am starting to convert my site from ASP to ASP.NET and I am wondering, I have a Google site serach that appears on every page of
the site. Can I nest this Google search form within the form tags of the web form ( I currently have it set up withn a MasterPage.master file) and everything still work?
What's the proper way to handle this? Can I even have multiple forms in one ASP.NET page or do I need to somehow turn them into controls or what? Please advise.
Mar 09, 2007 01:49 PM|Peter Smith|LINK
Mar 09, 2007 01:52 PM|Sojan80|LINK
Mar 09, 2007 01:55 PM|Peter Smith|LINK
You are right that the masterpage is technically a control and NOT a page.
what happens is that the contentplaceholders in the masterpage are translatoed to <div>'s and the actual .aspx content is placed inside them.
Just place the <form runat="server"> tag in the masterpage and you'll be fine.
if you've got any problems let me know.
Aug 17, 2007 08:50 PM|julian_julian_4|LINK
Ok but what if the Google (or any other) form is not to be in every page? Then it won't be feasible to place it in the Master Page.
I am actually trying to do that, and I end up with something like this:
<form name="form1" method="post" action="Pru2.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGR5v8mdcT3+VpyffLYWy2LYfihPuw==" />
<form id="hola" name="hola" method="get" action="Default.aspx">
<input id="Text1" type="text" />
<input id="Button1" type="button" value="button" />
So when I click the Button1 button, Internet Explorer 7 doesn't submit the correct form, it submits the parent form so my page (Pru2.aspx) is reloaded with nothing else happening.
What can I do?
<form method=get action=www.google.com/custom>
Aug 17, 2007 09:00 PM|Peter Smith|LINK
What you do is the following:
place the server side form on top in your masterpage.
that way the content of all the other pages with that masterpage as a masterpage, will be inside the serverside form..
The google form you require...you just put that ONLY in the pages where you require it.
Aug 18, 2007 11:26 AM|Sojan80|LINK
Actually I do this all the time only I do it a bit different.
I put it in a div that lives outside fo the form runat="server" tag in the master page and then us CSS to position it wherever it is I want it to go.