carter_jl
asked on
web page structure asp.net 1.1
I am trying to create a web page in asp.net 1.1. I want my pages to have a consistent feel. I already have the css for the pages
I am a php programmer and this is how I usually do it.
Click a link (FAQS index.php?faqs=1) it takes you to index.php.
index.php
example:
include ('top.php'); // top.php is the design for the top of the page
//this is where the content will be displayed
if(isset($_GET['faqs']))
{
include('faqs.php');
}
include ('bottom..php'); //bottom.php is the bottom of the page
I am a php programmer and this is how I usually do it.
Click a link (FAQS index.php?faqs=1) it takes you to index.php.
index.php
example:
include ('top.php'); // top.php is the design for the top of the page
//this is where the content will be displayed
if(isset($_GET['faqs']))
{
include('faqs.php');
}
include ('bottom..php'); //bottom.php is the bottom of the page
ASKER
I was doing that but I got an error:
A page can have only one server-side Form tag.
How can I bypass this problem?
A page can have only one server-side Form tag.
How can I bypass this problem?
>>I was doing that ...
it means that you create 3 user controls, for example top.ascx, bottom.ascx and faqs.ascx,
and a page for example detail.aspx, and then drag and drop user controls in the page(in design view)??
it means that you create 3 user controls, for example top.ascx, bottom.ascx and faqs.ascx,
and a page for example detail.aspx, and then drag and drop user controls in the page(in design view)??
ASKER
I followed those steps but I still have the error.
did you drag and drop the user controls in the page from the design view, from solution explorer?
ASKER
Yes.
This is the error:
A page can have only one server-side Form tag.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): A page can have only one server-side Form tag.]
System.Web.UI.Page.OnFormR ender(Html TextWriter writer, String formUniqueID) +311
System.Web.UI.HtmlControls .HtmlForm. RenderChil dren(HtmlT extWriter writer) +35
System.Web.UI.HtmlControls .HtmlForm. Render(Htm lTextWrite r output) +262
System.Web.UI.Control.Rend erControl( HtmlTextWr iter writer) +243
System.Web.UI.Control.Rend erChildren (HtmlTextW riter writer) +72
System.Web.UI.Control.Rend er(HtmlTex tWriter writer) +7
System.Web.UI.Control.Rend erControl( HtmlTextWr iter writer) +243
System.Web.UI.Control.Rend erChildren (HtmlTextW riter writer) +72
System.Web.UI.HtmlControls .HtmlForm. RenderChil dren(HtmlT extWriter writer) +44
System.Web.UI.HtmlControls .HtmlForm. Render(Htm lTextWrite r output) +262
System.Web.UI.Control.Rend erControl( HtmlTextWr iter writer) +243
System.Web.UI.Control.Rend erChildren (HtmlTextW riter writer) +72
System.Web.UI.Control.Rend er(HtmlTex tWriter writer) +7
System.Web.UI.Control.Rend erControl( HtmlTextWr iter writer) +243
System.Web.UI.Page.Process RequestMai n() +1918
This is the error:
A page can have only one server-side Form tag.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): A page can have only one server-side Form tag.]
System.Web.UI.Page.OnFormR
System.Web.UI.HtmlControls
System.Web.UI.HtmlControls
System.Web.UI.Control.Rend
System.Web.UI.Control.Rend
System.Web.UI.Control.Rend
System.Web.UI.Control.Rend
System.Web.UI.Control.Rend
System.Web.UI.HtmlControls
System.Web.UI.HtmlControls
System.Web.UI.Control.Rend
System.Web.UI.Control.Rend
System.Web.UI.Control.Rend
System.Web.UI.Control.Rend
System.Web.UI.Page.Process
how do you insert a user control to your solution?
did you create a page and then rename it to ascx?
did you create a page and then rename it to ascx?
ASKER
Yes, I think the problem is that I have two runat="server" in the code, because of the user control, and a regular text box.
you don't create the ascx user controls like this,
you should insert a user control to a solution in this way:
right click on your project in solutionb explorer, and then "Add" --> "Add Web User Control"
you should insert a user control to a solution in this way:
right click on your project in solutionb explorer, and then "Add" --> "Add Web User Control"
i do exactly the same thing you are trying to do. Here is what you are looking for
in html
<asp:placeholder runat=server id=ph1 />
in page load event
dim controller as string = request.querystring("contr oller")
if controller = "page1" then
dim c as control = page.loadcontol(request.ap plicationp ath + "/UserControls/Page1.ascx" )
ph1.controls.add(c)
elseif controller = "page2" then
dim c as control = page.loadcontol(request.ap plicationp ath + "/UserControls/Page2.ascx" )
ph1.controls.add(c)
and so on..
in html
<asp:placeholder runat=server id=ph1 />
in page load event
dim controller as string = request.querystring("contr
if controller = "page1" then
dim c as control = page.loadcontol(request.ap
ph1.controls.add(c)
elseif controller = "page2" then
dim c as control = page.loadcontol(request.ap
ph1.controls.add(c)
and so on..
ASKER
in html
<asp:placeholder runat=server id=ph1 />
in page load event
string controller = Request.QueryString.Get("c ontroller" );
if(controller == "abc")
{
Control c = Page.LoadControl(Request.A pplication Path + "/abcContent.ascx");
ph1.Controls.Add(c);
}
in abcContent.ascx
<%@ Control Language="C#" EnableViewState="False" %>
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" runat="server"></asp:TextB ox></P>
</form>
I still continue to get the same error.
<asp:placeholder runat=server id=ph1 />
in page load event
string controller = Request.QueryString.Get("c
if(controller == "abc")
{
Control c = Page.LoadControl(Request.A
ph1.Controls.Add(c);
}
in abcContent.ascx
<%@ Control Language="C#" EnableViewState="False" %>
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" runat="server"></asp:TextB
</form>
I still continue to get the same error.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
true, you have to actually have a user control.
ASKER
Sorry about the delay in giving you your points. I tested your solution and I appreciate all of your help.
have a good programming day;
you can create and code usercontrols like pages, and when you finished them, you can make a page(*.aspx), and then drag an drop your ascx where you want in your page