Solved

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

Posted on 2007-11-20
2
789 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

Technology Partners: 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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

738 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