Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Casting a Variable to User control

Reply
Thread Tools

Casting a Variable to User control

 
 
Dinu
Guest
Posts: n/a
 
      07-31-2007
How to Cast a Variable to User control in ASP.NET using vb.net as code-
behind

 
Reply With Quote
 
 
 
 
Peter Bucher [MVP]
Guest
Posts: n/a
 
      07-31-2007
Hello Dinu

> How to Cast a Variable to User control in ASP.NET using vb.net as code-
> behind


Dim myUserControl As UserControl = DirectCast(<var>, UserControl)

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET


 
Reply With Quote
 
 
 
 
Dinu
Guest
Posts: n/a
 
      07-31-2007
On Jul 31, 5:25 pm, "Peter Bucher [MVP]" <(E-Mail Removed)>
wrote:
> Hello Dinu
>
> > How to Cast a Variable to User control in ASP.NET using vb.net as code-
> > behind

>
> Dim myUserControl As UserControl = DirectCast(<var>, UserControl)
>
> --
> Gruss, Peter Bucher
> Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerlandhttp://www.aspnetzone.de/- ASP.NET Zone, die ASP.NET Communityhttp://www.aspnetzone.de/blogs/peterbucher/- Auf den Spuren von .NET


Hi
thanks for ur response,

can we use Ctype method??

 
Reply With Quote
 
Dinu
Guest
Posts: n/a
 
      07-31-2007
Hi Peter,

Can u tell me how can we dynamically access properties of a user
control
in master page from a content page and set properties of user control
in master page from content page


thanks

 
Reply With Quote
 
Peter Bucher [MVP]
Guest
Posts: n/a
 
      07-31-2007
Hi Dinu

> can we use Ctype method??

Yes you can, read:
- http://www.google.ch/search?hl=de&q=...rectcast&meta=

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET


 
Reply With Quote
 
Peter Bucher [MVP]
Guest
Posts: n/a
 
      07-31-2007
Hi Dinu

> Can u tell me how can we dynamically access properties of a user
> control
> in master page from a content page and set properties of user control
> in master page from content page

Access the masterpage in a contentpage with this.Master.Page, use further
the .FindControl() methode
of the masterpage to find the usercontrol. (Or use .FindControl twice, for
the ContainerControl in the masterpage AND then for the specific usercontrol
within the container.
then cast the usercontrol (Control) to (UserControl) and access the
properties you want.

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Control to Control Other User Control Jonathan Wood ASP .Net 4 02-02-2010 03:41 PM
Up casting and down casting Sosuke C++ 2 12-20-2009 03:24 PM
Problem with depracated casting method (down casting) Wally Barnes C++ 3 11-20-2008 05:33 AM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr ASP .Net 0 03-22-2006 08:02 AM
Another question about inheritance (up-casting and down-casting) kevin Java 11 01-08-2005 07:11 PM



Advertisments