Solved

web page structure asp.net 1.1

Posted on 2006-07-12
15
264 Views
Last Modified: 2008-02-01
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
0
Comment
Question by:carter_jl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
  • 2
15 Comments
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17092969
in asp.net you can use UserControls(*.ascx),

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
0
 

Author Comment

by:carter_jl
ID: 17093000
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?
0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17093056
>>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)??
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:carter_jl
ID: 17093254
I followed those steps but I still have the error.
0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17093366
did you drag and drop the user controls in the page from the design view, from solution explorer?
0
 

Author Comment

by:carter_jl
ID: 17093386
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.OnFormRender(HtmlTextWriter writer, String formUniqueID) +311
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +35
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +262
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
   System.Web.UI.Control.Render(HtmlTextWriter writer) +7
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +44
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +262
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
   System.Web.UI.Control.Render(HtmlTextWriter writer) +7
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
   System.Web.UI.Page.ProcessRequestMain() +1918

 
0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17093444
how do you insert a user control to your solution?
did you create a page and then rename it to ascx?
0
 

Author Comment

by:carter_jl
ID: 17093503
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.
0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17093677
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"

0
 
LVL 8

Expert Comment

by:rodmjay
ID: 17093786
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("controller")

if controller = "page1" then
 dim c as control = page.loadcontol(request.applicationpath + "/UserControls/Page1.ascx")
 ph1.controls.add(c)
elseif controller = "page2" then
 dim c as control = page.loadcontol(request.applicationpath + "/UserControls/Page2.ascx")
 ph1.controls.add(c)
and so on..
0
 

Author Comment

by:carter_jl
ID: 17094060
in html
<asp:placeholder runat=server id=ph1 />

in page load event
string controller = Request.QueryString.Get("controller");

                  if(controller == "abc")
                  {
                        Control c = Page.LoadControl(Request.ApplicationPath + "/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:TextBox></P>
      </form>

I still continue to get the same error.
0
 
LVL 9

Accepted Solution

by:
zaghaghi earned 500 total points
ID: 17094094
you should create a user control, by adding a user control to your solution not to rename a web page

see this:

its a page source:
<%@ Page language="c#" Codebehind="WebForm.aspx.cs" AutoEventWireup="false" Inherits="eeapplicationcs.WebForm" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > 

<html>
  <head>
    <title>WebForm</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name=vs_defaultClientScript content="JavaScript">
    <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
  </head>
  <body MS_POSITIONING="GridLayout">
      
    <form id="Form1" method="post" runat="server">

     </form>
      
  </body>
</html>

and its a user control source:

<%@ Control Language="c#" AutoEventWireup="false" Codebehind="WebUserControl.ascx.cs" Inherits="eeapplicationcs.WebUserControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>


as you see there is no form in the user control source
0
 
LVL 8

Expert Comment

by:rodmjay
ID: 17094507
true, you have to actually have a user control.
0
 

Author Comment

by:carter_jl
ID: 17101427
Sorry about the delay in giving you your points. I tested your solution and I appreciate all of your help.
0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 17106231
have a good programming day;
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question