首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

asp.net中的自定义控件有关问题,在线焦急等待中.

2012-02-22 
asp.net中的自定义控件问题,在线焦急等待中.........用户自定义控件类usingSystemusingSystem.Web.UIusi

asp.net中的自定义控件问题,在线焦急等待中.........
用户自定义控件类

using   System;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.IO;
///   <summary>
///   SubHeader   用户自定义控件
///   </summary>
namespace   FriendsReunion
{
        public   class   SubHeader   :   WebControl
        {
                //The   URL   to   navigate   to   if   the   user   is   not   registered
                private   string   _register   =   String.Empty;
                public   string   RegisterUrl
                {
                        get   {   return   _register;   }
                        set   {   _register   =   value;   }
                }

                public   SubHeader()
                {
                        //
                        //   TODO:   在此处添加构造函数逻辑
                        //

                        //Initailize   the   default   values
                        this.Width   =   new   Unit(100,   UnitType.Percentage);
                        this.CssClass   =   "SubHeader ";
                }

                //This   method   is   called   when   the   control   is   being   built
                protected   override   void   CreateChildControls()
                {
                        //Clear   any   previously   loaded   controls
                        this.Controls.Clear();
                        Label   lbl;

                        //If   the   user   is   authenticated,we   will   render   their   name
                        if   (Context.User.Identity.IsAuthenticated)
                        {
                                lbl   =   new   Label();
                                lbl.Text   =   Context.User.Identity.Name;



                                //Add   the   newly   created   label   to   our   collection   of   child   controls
                                this.Controls.Add(lbl);
                        }
                        else
                        {
                                //Otherwise,we   will   render   a   link   to   the   registration   page
                                HyperLink   reg   =   new   HyperLink();
                                reg.Text   =   "Register ";

                                //If   a   URL   is   not   provided   ,use   a   default   URL   to   the   registration   page
                                if   (_register   ==   String.Empty)
                                {
                                        reg.NavigateUrl   =   Context.Request.ApplicationPath   +
                                                Path.AltDirectorySeparatorChar   +   "Secure "   +
                                                Path.AltDirectorySeparatorChar   +   "NewUser.aspx ";
                                }
                                else
                                {
                                        reg.NavigateUrl   =   _register;
                                }
                                this.Controls.Add(reg);
                        }

                        //Add   a   couple   of   blank   spaces   and   a   separator   character
                        this.Controls.Add(new   LiteralControl( "&nbsp;-&nbsp; "));



                        //Add   a   label   with   the   current   data
                        lbl   =   new   Label();
                        lbl.Text   =   DateTime.Now.ToLongDateString();
                        this.Controls.Add(lbl);

                        //base.CreateChildControls();
                }
        }

}


在Web页面的引用语句为:
<%@   Register   TagPrefix= "wx "   Namespace= "FriendsReunion "                           Assembly= "FriendsReunion.SubHeader "   %>
 

...


<wx:SubHeader   id= "SubHeader1 "   runat= "server "   />


编译报错:
错误1
未能加载文件或程序集“FriendsReunion.SubHeader”或它的某一个依赖项。系统找不到指定的文件。
错误2
未知的服务器标记“wx:SubHeader”。


请高手解答






[解决办法]
Assembly= "FriendsReunion.SubHeader "
这个是这个控件所在的程序集名字么?



[解决办法]
有文件丢失!
[解决办法]
直接拖过来 就会自动生成

热点排行