Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2005, 06:52 AM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default aspx elements seemingly appearing out of nowhere.

I'm new to asp.net and started with asp.net2. I am currently looking at a page which displays a menu at the top and content below.

Code:
<%@ Page Language="c#" Inherits="Dcoms.Admin.Web.UI.OrderMenuPage" Trace="False" EnableViewState="False" %>
<%@ Register TagPrefix="Dcoms" TagName="SubMenuBar" Src="./UserControls/SubMenuBar.ascx" %>
<%@ Register TagPrefix="Dcoms" Namespace="Dcoms.Web.UI.ServerControls" Assembly="Dcoms.Web" %>
<Asp:Panel ID="MiddlePane" RunAt="Server">
    <Dcoms:CustomPanel RunAt="Server" Width="350px" StyleNumber="1" HeaderText="Order Menu">
        <Dcoms:SubMenuBar ID="OrderSubMenu" RunAt="Server" />
    </Dcoms:CustomPanel>
</Asp:Panel>
Now this is what I don't understand, how does asp.net know to put the menu bar at the top when I don't see any reference to the menu bar in the page. As a matter of fact all the content pages in the project are like that. In asp.net 2.0 you could use master pages to do this, how is it done here?

EDIT1: Also how can CustomPanel Control be used without a matching register header?
 
Old December 12th, 2005, 04:36 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

1. Is this not the menu bar you are asking about?:
   <Dcoms:SubMenuBar ID="OrderSubMenu" RunAt="Server" />
If not then first I'd trace back thru the class inheritance chain starting here: Dcoms.Admin.Web.UI.OrderMenuPage. See what happens on each parent class. Perhaps something is programmatically adding in the menu bar to the page controls.

2. The second tag registration is referencing an assembly (Dcoms.Web) which most likely contains more than one control (versus a file reference to an ASCX that makes up a single control). Presumably, there is a class in that assembly named 'CustomPanel'.

-Peter
 
Old December 14th, 2005, 02:45 AM
Registered User
 
Join Date: Dec 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

After some research on about the answers supplied for my previous questions, I have come across two further questions which I would like to ask. They are:

1. How come this aspx page is able to run fine in the web browser when the page seems to be devoid of html main tags, like <html> <body> etc. I've had a look at the custompanel code and and it is basically just some content tags in a <div>.

2. All the examples I have found on the web about custom controls are like this <tag /> tags. What does it mean when a custom control encases another custom control? How do you leave space in the first custom control for the render code of the second custom control (if that is indeed the purpose)?

Here is the class for customcontrol if that helps:

namespace Dcoms.Web.UI.ServerControls
{
    public class CustomPanel : Panel
    {
        public int StyleNumber
        {
            .......
        }
        public virtual string HeaderText
        {
            ...
        }

        /// <summary>
        /// We want to add 2 container - the first div being the header container
        /// and the second div being the main container
        /// </summary>
        protected override void RenderContents(HtmlTextWriter writer)
        {
            string styleNumber = StyleNumber.ToString();

            string headerCssClass = "CustomPanel" + styleNumber + "Header";
            string contentCssClass = "CustomPanel" + styleNumber + "Content";

            writer.AddAttribute(HtmlTextWriterAttribute.Class, headerCssClass);
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            writer.Write(this.HeaderText);
            writer.RenderEndTag();

            writer.AddAttribute(HtmlTextWriterAttribute.Class, contentCssClass);
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            base.RenderContents(writer);
            writer.RenderEndTag();
        }
    }
}

 
Old December 15th, 2005, 11:45 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

1. The browser will likely display the contents of an HTML page even if it's missing the main tags usually found on such pages. The browser have seemed to become a bit more tolerant of malformed HTML.

2. I'm no expert on building custom controls. I've built a lot of user controls but they behave a bit different.

Generally speaking, most controls that can include child controls will call the render method on the child controls they contain.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
unneccsarry objects appearing harj VS.NET 2002/2003 5 April 29th, 2008 07:09 AM
instead of font boxes appearing macdev BOOK: Beginning Mac OS X Programming 1 August 22nd, 2007 05:27 AM
Database not appearing in browser sevans BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 May 30th, 2007 06:46 AM
Debug example seemingly not quite right on page 78 kowalke BOOK: Beginning Mac OS X Programming 5 August 17th, 2006 02:04 PM
Seemingly Complicated Query help needed krashed SQL Language 5 March 31st, 2006 01:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.