Solved

How to "cast" a Control var referencing a Web User Control

Posted on 2007-11-20
2
783 Views
Last Modified: 2008-02-01
I know that I can do this in order to add a Web User Control to a PlaceHolder at runtime:

Control c = LoadControl("..\\scripts\\controls\\FUWStepMonitor\\FUWStepMonitor.ascx");
        msgbox.Controls.Add(c);

but afterwards, how do I reference the control inside the collection, such that I can get to the public methods of the Web User Control?

(( cast ??? } msgbox.Controls.FindControl[ ??? ]). some public method ( )
0
Comment
Question by:knowlton
2 Comments
 
LVL 5

Author Comment

by:knowlton
Comment Utility
Oooooookay:

This seems to work just fine:

((members_beta_scripts_controls_FUWStepMonitor_FUWStepMonitor)c).SetVisibleButtons(true, true, false, false);


Is there a way to "deal with" or provide an alias for that EXTREMELY LONG class name?
0
 
LVL 12

Accepted Solution

by:
AGBrown earned 500 total points
Comment Utility
That's what you are stuck with unless you change the class name by going into the ascx.cs file, and then updating the .ascx file's "Inherits" attribute of the Control directive to reflect the new name.

VS Web Developer doesn't put classes into namespaces based on the folder hierarchy, instead it postfixes each folder name with an underscore and puts them all together into the name. I prefer to change that and create namespaces that reflect the folder hierarchy, and then you can use "using" statements, or similar, to denote classes. e.g.

using members.beta.scripts.controls.FUWStepMonitor;
...
((FUWStepMonitor)c).SetVisibleButtons....
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now