Getting the namespace name for an ASP.net control

Therefore, I am having problems when I try to publish a website. I am in visual studio 2008 sp1.

I have a bunch of custom controls, and on several pages I use them programmatically.

I have a link on an aspx page

<%@ Reference Control="~/UserControls/Foo.ascx" %>

Then using code I use

ASP.usercontrols_foo newFoo control = (ASP.usercontrols_foo)Page.LoadControl("~/UserControls/Foo.ascx");

If I go to the page, it will be fine, but when I go to the site, I will get a compile-time error.

+3
source share
8 answers

Arg, I'm bleeding hours of development on the same issue. Anyone have a solution?

BTW: , " " ( -, " ", " MSBuild" )

, .

+6

- , , .

:

ASP.usercontrols_foo newFoo control = (ASP.usercontrols_foo)Page.LoadControl("~/UserControls/Foo.ascx");

USERCONTROLS_Foo newFoo control = (USERCONTROLS_Foo)Page.LoadControl("~/UserControls/Foo.ascx");

( , / , ).

+2
+1

. , , ASP aspx.

+1

, , . , :

Control control = Page.LoadControl("~/UserControls/Foo.ascx");
0

, Control. usercontrol.

, , , , .

, , ,

<%@ Register src="CategoryRows.ascx" tagname="CategoryRows" tagprefix="abc" %>
<abc:CategoryRows ID="CategoryRows" runat="server" />

, , , XCopy ( ). .

0

. MYM (, ), , , System.Web.UI.UserControl. cotrol System.Web.UI.UserControl .

, . .

0

, :

website.publishproj?
, .

0

Source: https://habr.com/ru/post/1707704/


All Articles