Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Awareness of user control TestContainer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
michael sorens - 28 Mar 2008 00:43 GMT
In my code for a custom user control, is there a way to determine whether or
not I am inside the standard user control TestContainer? I was hoping that I
could perhaps examine a unique characteristic of the parent, if it is
accessible. Ultimately what I would like to do is exercise more of my custom
control  than just seeing how it renders, something along the lines of: if
inside the TestContainer, then show a hidden "Step" button. I could then
press the Step button to make the control do some action; press it again for
the next action, etc.

I am running VS2008, with .NET 2 or 3 or 3.5.
Steven Cheng [MSFT] - 28 Mar 2008 04:25 GMT
Hi Michael,

As or the custom user control, do you mean the ascx user control(or a
custom server control)?

I'm still not quite sure about the "TestContainer" you mentioned, is it the
parent container of a control on page at runtime?Generally, for any ASP.NET
server control on page, it will have a NamingContainer(if it is not the top
level control), and this NamingContainer will affect the control's actual
UniqueID and ClientID when rendering. Control can access its
NamingContainer through the "NamingContainer" property at runtime.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= <m_j_sorens@newsgroup.nospam>
>Subject: Awareness of user control TestContainer
>Date: Thu, 27 Mar 2008 16:43:01 -0700

>In my code for a custom user control, is there a way to determine whether or
>not I am inside the standard user control TestContainer? I was hoping that I
[quoted text clipped - 6 lines]
>
>I am running VS2008, with .NET 2 or 3 or 3.5.
michael sorens - 28 Mar 2008 14:39 GMT
Sorry for the ambiguity... this is a WinForm not a WebForm. The User Control
TestContainer is a vehicle of Visual Studio that automatically runs a user
control when you press F5 for a user control library project.
Steven Cheng [MSFT] - 31 Mar 2008 04:02 GMT
Thanks for the reply Michael,

Seems I also incorrectly assume that this is an ASP.NET issue(as I often
see your posts on ASP.NET :) ).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= <m_j_sorens@newsgroup.nospam>
>References:  <02A640DA-A44D-4EA7-B654-A07010155820@microsoft.com>
<CFtCvNIkIHA.6264@TK2MSFTNGHUB02.phx.gbl>
>Subject: RE: Awareness of user control TestContainer
>Date: Fri, 28 Mar 2008 06:39:00 -0700

>Sorry for the ambiguity... this is a WinForm not a WebForm. The User Control
>TestContainer is a vehicle of Visual Studio that automatically runs a user
>control when you press F5 for a user control library project.
Linda Liu[MSFT] - 31 Mar 2008 07:45 GMT
Hi Michael,

Thank you for your reply!

Based on my understanding, you have a user control class library project
which contains a custom user control and you create a test project for the
custom user control. What you want is to determine from within the custom
control's code whether the custom control is created inside a test
container. If I'm off base, please feel free to let me know.

IMO, the custom control has no chance to know whether it is created inside
a test container or not. All classes and methods provided by the Unit
Testing Framework are used in test class and methods, rather that in the
classes or methods to test.

A workaround of your question is to add a property of type bool in the
custom control to indicate whether it is initialized inside a test
container or not. The default value of this property is false. You can set
this property to true from within the test method. You can then decide how
the custom control renders depending on this bool property.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.