Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-11-20
2
Medium Priority
?
792 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

688 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