473,776 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Casting a Variable to User control

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

Jul 31 '07 #1
5 3266
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
Jul 31 '07 #2
On Jul 31, 5:25 pm, "Peter Bucher [MVP]" <peter.buc...@a spnetzone.de>
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??

Jul 31 '07 #3
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

Jul 31 '07 #4
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
Jul 31 '07 #5
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.Pag e, use further
the .FindControl() methode
of the masterpage to find the usercontrol. (Or use .FindControl twice, for
the ContainerContro l 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
Jul 31 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1220
by: Keith Selbee | last post by:
I have a file that provides details on which user control to populate a web page with at runtime. I'm able to create and load the control successfully, but now I need to cast it from Control to its specific type so I can access it's specific members. I have the type as a string ("MyUserControl" for example). So, having the name, how do I cast it from Control to this type? Thanks... Keith
7
3679
by: yufufi | last post by:
lets say we have a 'shape' class which doesn't implement IComparable interface.. compiler doesn't give you error for the lines below.. shape b= new shape(); IComparable h; h=(IComparable)b; but it complains for the following lines
8
2136
by: Michael | last post by:
Hi, I think my problem deals with class casting and inheritance. I want to deal with various Audio Formats, reading into memory for modification, working with it (done by different classes), and writing the result to disk afterwards. Therefore I have created some classes, e.g. WaveFileIO and AiffFileIO and MP3FileIO and AuFileIO for the In/Out operations.
3
6196
by: Ron | last post by:
Hi all, I've come across a problem when casting user controls in ASP.NET 2.0, hopefully someone can help. I have a master page with a user control on it (myMenu) that I wish to programmatically access from a content page. Below is how I am trying to do this (this would work in ASP.NET 1.1). DynamicMenu myMenu = (DynamicMenu)((MasterPage)this.Master).FindControl("myMenu");
4
14536
by: Vincent | last post by:
Regarding the dropdetect function, defined as follows: Sub dropdetect(DropFrm As Form, DropCtrl As Control, Button As Integer, Shift As Integer, X As Single, Y As Single) Is it possible to cast the Control parameter, DropCtrl, to a TextBox object? The underlying control is in fact a textbox which I wish to redraw given the X and Y parameters above. In Java, you could simply declare a TextBox reference and assign it to the Control...
12
13653
by: 6tc1 | last post by:
Hi all, I just discovered a rounding error that occurs in C#. I'm sure this is an old issue, but it is new to me and resulted in a fair amount of time trying to track down the issue. Basically put the following code into your C# app: float testFloat2 = (int) (4.2f * (float)100); Console.Out.WriteLine("1: "+testFloat2); and the result will be 419
5
2195
by: Ronald Raygun | last post by:
If I have the following class heirarchy: class A{ protected $m_type; function type(){return $this->m_type;} } class B extends A{} class C extends B{}
19
1954
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
I'm doing my c# more and more like i used to code c++, meaning i'm casting more often than creating an instance of objects. like : protected void gvOrderDetailsRowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { switch (((Sale)e.Row.DataItem).SzPN) {
4
4404
by: AndreH | last post by:
Good day, I have the a bit of an issue with retrieving an object from php's session. I set a session variable "user" from the class User as follows: $user = new User(); // ... do some stuff to $user $_SESSION = serialize($user);
0
9462
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9922
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8951
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7469
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5367
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5492
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3621
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2859
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.