Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-20
2
Medium Priority
?
794 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:Tom Knowlton
2 Comments
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 20323472
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 2000 total points
ID: 20330376
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Screencast - Getting to Know the Pipeline
Suggested Courses

972 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