Hello Tim,
Nice to see you again.
As for the global usercontrol's reference type in page (when using VS 2005
Web application project), I've just perfomed some test against a Web
Applicaiton project on my side and did find the behavior you mentioned.
Actually, this behavior is due to the limitation of globally registered
usercontrols in web.config file(<pages><controlssection). Since the
usercontrol registered there doesn't add a @register directive(like below)
, then the page parser can not determine the concrete type of the
usercontrol, thus, use the base class UserControl instead.
<%@ Register TagName="" TagPrefix="" Src=""%>
Currently, based on my test, a possible approach is manually declare the
usercontrol member variable in our page's codebehind file(not the
designer.cs file). Because ASP.NET 2.0 Web application project use the
following to file to compile the two partial page class:
** pagename.aspx.cs
**pagename.aspx.designer.cs
and pagename.aspx.deisgner.cs is changeable(whenever we modify the page),
therefore, we should manually declare the usercontrol member in the
pagename.aspx.cs file which is not auto generated by IDE. e.g.
#first remove the originally generated member variable for your usercontrol
in the designer.cs file(which is of UserControl class), then add the
concrete usercontrol type member variable in main cs codebehind as below:
========================
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected GpTemplate gp1;
.........................
}
}
====================
After that, the page parser will automatically use this member variable to
associate the usercontrol in aspx template and won't regenerate the
UserControl type member in designer.cs file.
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.