I'm trying to include a user control in an aspx page, it works fine, but my control does position itself where I want it and always appears at the very top of the page. Could it have something to do with the masterpage? I've tried registering the user control in the master page, but I don't know how to reference it in the content page. Any ideas?
In my Default.aspx page I register my usercontrol at the top:
<%@ Language="VB" MasterPageFile="~/Master-Pages/Landing1.master" AutoEventWireup="false"
Title="Home" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Src="/Controls/News.ascx" TagName="HomepageNews" TagPrefix="uc" %>
Then in my page I try inc开发者_开发百科lude the control:
<asp:Content ID="NewsArea" ContentPlaceHolderID="ContentBottomCol" Runat="Server">
<%@ Register Src="/Controls/News.ascx" TagName="HomepageNews" TagPrefix="uc" %>
</asp:Content>
To include the UserControl in a page you would register it at the top using a Register directive and then include its tag like any other control.
So:
<%@ Language="VB" MasterPageFile="~/Master-Pages/Landing1.master" AutoEventWireup="false"
Title="Home" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Src="/Controls/News.ascx" TagName="HomepageNews" TagPrefix="uc" %>
...
<asp:Content ID="NewsArea" ContentPlaceHolderID="ContentBottomCol" Runat="Server">
<uc:MyNewsUserControl ID="MyNewsUserControl1" runat="server"> </uc:MyNewsUserControl>
</asp:Content>
精彩评论