Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# Namespace/class alias in Visual Studio Html Source mode

Is there any way to create a Namespace alias in a .aspx file (not code-behind .aspx.cs).

For example... in a code-behind file an alias can be created as follows:

using MyPanel = System.Web.UI.WebControls.Panel;

In html source mode (Visual Studio) a Namespace can be imported as follows:

<%@ Import Namespace="System.Web.UI.WebControls" %>

What I need to do is something like the following:

<%@ Import Namespace="MyPanel = System.Web.UI.WebControls.Panel" %>

EDIT/UPDATE: Obviously that does not work. Is it possible some other way without using code-behind? Yes, it actually does work if you remove the whitespace (hat tip @Alex below). Example:

<%@ Import Namespace="MyPanel=System.Web.UI.WebControls.Panel" %>
like image 548
jlang Avatar asked Apr 27 '26 04:04

jlang


1 Answers

Actually, your third example does work. You need to get rid of the white space. To get your ASPX namespace alias working, write the namespace declaration like this:

<%@ Import Namespace="MyPanel=System.Web.UI.WebControls.Panel" %>

like image 121
Alex Avatar answered Apr 29 '26 18:04

Alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!