Problem in using one user control in another user control in asp.net C#
I have problem in using one user control in another user control in C#. This is the code.
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CustomerDetail.ascx.cs"
Inherits="Controls_CustomerDetail" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/PL_Controls/Admin/AddAddress.ascx" TagPrefix="CustomerAddress" TagName="Address" %>
<%--<%@ Register Src="~/PL_Controls/Admin/AddAddress.ascx" TagPrefix="UC" TagName="AddAddress" %>--%>
<style type="text/css">
.overlay_style
{
background: #777777;
opacity: 0.7;
filter: alpha(opacity=70);
}
</style>
<div runat="server" id="divaddress"
style="border-style: dashed; background: golden; background-color: #C0C0C0; display: block;">
<CustomerAddress:Address Id="CustomerAddress" runat="server" />
</div>
This shows green line below "Address: in div tag with message that Address is not a non 开发者_C百科element,. This can occur if there is compilation error in web site or web.config file is missing. But I have web.config in my application. When I try to use this user control in server side code using its ID, it is not available at server side. Please help me to get rid our of these problem...
Try changing the Id to something other than CustomerAddress - you probably are running into a name collision issue.
Make sure that the designer.cs file declares the user control instance. Also, if the user controls are in the same assembly, and you're referencing them via web.config, that could cause problems as well.
Manually declare CustomerAddress
in your designer.cs file then build your project. You will see a more related error for this problem.
精彩评论