Solved

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

Posted on 2007-11-20
2
791 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

628 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