简体   繁体   中英

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" %>

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" %>

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" %> 

One contol is blocking another control:theetat When I am trying to run my codedUITest to set some text in my edit box I get the following error:

Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnBlockedControlException: Another control is blocking the control. Please make the blocked control visible and retry the action. I have had this issue before and I have been able to work around it by clicking on the center of the text box like so:

Mouse.Click(new System.Drawing.Point(sentControl.BoundingRectangle.Width / 2 + sentControl.BoundingRectangle.X, sentControl.BoundingRectangle.Height / 2 + sentControl.BoundingRectangle.Y));

Where "sentControl" is the control that you want to click. Then do a SendKeys("mystuff") to the window as a whole.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM