在aspx页面上注册时的ascx用户控件 [英] ascx user control when it's been registered on aspx page
问题描述
我已经在appx控件的顶部注册了一个用户控件.
Hi I've registered a user control on the top of an appx control.
<%@ Register Src="../Controls/Attachments.ascx" TagName="Attachments" TagPrefix="uc7" %>
<%@ Register Src="../Controls/Help.ascx" TagName="Help" TagPrefix="uc8" %>
<%@ Register Src="~/Controls/WRControls/WRDetails.ascx" TagName="WR" TagPrefix="uc9" %>
不幸的是,当我尝试调用新的用户控件时.即
Unfortunately when I try to call the new user control. i.e
"< uc9:WR"
(uc9:WR不会出现在ittelisense下拉列表中).
"<uc9:WR"
(uc9:WR does not appear in the ittelisense drop down) for the new user control which I've added.
基本用户控件与其他用户控件位于不同的文件路径下.如您在上面看到的.
The base user control is under a different file path to other user controls. As you can see above.
由于无法在智能感知中找到用户控件,因此无法将控件添加到aspx页面.
As i'm unable to find the user control in the intellisense I can then not add the control to the aspx page.
我已经在基本控件上进行了各种尝试,即删除designer.cs页面中的所有代码,然后剪切并重新粘贴html以重新生成designer.cs页面,但无济于事.
I've tried all sorts onthe base control i.e deleting all code in the designer.cs page then cutting and re-pasting the html to re-generate the designer.cs page all to no avail.
推荐答案
将用户控件注册到web.config文件中,如本文所示:
Register your user control in the web.config file as shown in this article:
在web.config文件的< pages>
下,添加一个< controls>
块,如下所示:
Under <pages>
in the web.config file, add a <controls>
block as follows:
<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="scottgu" src="~/Controls/Header.ascx" tagName="header"/>
<add tagPrefix="scottgu" src="~/Controls/Footer.ascx" tagName="footer"/>
<add tagPrefix="ControlVendor" assembly="ControlVendorAssembly"/>
</controls>
</pages>
</system.web>
</configuration>
这篇关于在aspx页面上注册时的ascx用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!