Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspdotnet_website_programming thread: Re: SiteHeader can not work.


Message #1 by "Greg Lester" <gslester123@h...> on Tue, 5 Nov 2002 08:37:35
I am having the same problem.  The whole page looks good except that it is 
missing the Greeting Label.  It just won't display at all.  Any insite?

Here is an abreviated example.

Default.aspx:

<%@ Page Language="c#" AutoEventWireup="false" %>
<%@ Register TagPrefix="WroxUser" TagName="SiteHeader" 
Src="Controls/SiteHeader.ascx" %>

<body>
  <form id="Default" method="post" runat="server">
    <WroxUser:SiteHeader id="Header" runat="server"/><br>
  </form>
</body>

SiteHeader.ascx:

<%@ Control Language="c#" AutoEventWireup="false" 
Codebehind="SiteHeader.ascx.cs" 
Inherits="Wrox.ThePhile.Web.Controls.User.SiteHeader" 
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>\

<asp:Label id="Greeting" runat="server">

SiteHeader.ascx.cs:

namespace Wrox.ThePhile.Web.Controls.User
{
	using System;
	using System.Web;
	using System.Web.UI;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;

	public abstract class SiteHeader : UserControl
	{
		protected Label Greeting;


		private void Page_Load()
		{
			Greeting.Text = "Welcome";
		}
	}
}

> Hi
I>  read this book(ASP.NET Website Programming) to P.73
W> hen I finished the default.aspx
I>  can see the page, siteheader, sitefooter, navmenu are work.
B> ut can not display SiteHeader's "Welcome, Guest User" wording.
I>  zip my files and everyone can download via:
h> ttp://www.allenkuo.com/temp/thephile.zip

> Can you tell me why and how to fix? Thank you.
Message #2 by "Greg Lester" <gslester123@h...> on Tue, 5 Nov 2002 09:13:45
Nevermind.  I was missing:
  override protected void OnInit(EventArgs e)
  {
    InitializeComponent();
    base.OnInit(e);
  }

  private void InitializeComponent()
  {
    this.Load += new System.EventHandler(this.Page_Load);
  }

> I am having the same problem.  The whole page looks good except that it 
is 
m> issing the Greeting Label.  It just won't display at all.  Any insite?

> Here is an abreviated example.

> Default.aspx:

> <%@ Page Language="c#" AutoEventWireup="false" %>
<> %@ Register TagPrefix="WroxUser" TagName="SiteHeader" 
S> rc="Controls/SiteHeader.ascx" %>

> <body>
 >  <form id="Default" method="post" runat="server">
 >    <WroxUser:SiteHeader id="Header" runat="server"/><br>
 >  </form>
<> /body>

> SiteHeader.ascx:

> <%@ Control Language="c#" AutoEventWireup="false" 
C> odebehind="SiteHeader.ascx.cs" 
I> nherits="Wrox.ThePhile.Web.Controls.User.SiteHeader" 
T> argetSchema="http://schemas.microsoft.com/intellisense/ie5" %>\

> <asp:Label id="Greeting" runat="server">

> SiteHeader.ascx.cs:

> namespace Wrox.ThePhile.Web.Controls.User
{> 
	> using System;
	> using System.Web;
	> using System.Web.UI;
	> using System.Web.UI.WebControls;
	> using System.Web.UI.HtmlControls;

> 	public abstract class SiteHeader : UserControl
	> {
	> 	protected Label Greeting;

> 
	> 	private void Page_Load()
	> 	{
	> 		Greeting.Text = "Welcome";
	> 	}
	> }
}> 

> > Hi
I> >  read this book(ASP.NET Website Programming) to P.73
W> > hen I finished the default.aspx
I> >  can see the page, siteheader, sitefooter, navmenu are work.
B> > ut can not display SiteHeader's "Welcome, Guest User" wording.
I> >  zip my files and everyone can download via:
h> > ttp://www.allenkuo.com/temp/thephile.zip

> > Can you tell me why and how to fix? Thank you.

  Return to Index