Casting a Variable to User control

Discussion in 'ASP .Net' started by Dinu, Jul 31, 2007.

  1. Dinu

    Dinu Guest

    How to Cast a Variable to User control in ASP.NET using vb.net as code-
    behind
    Dinu, Jul 31, 2007
    #1
    1. Advertising

  2. 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
    Peter Bucher [MVP], Jul 31, 2007
    #2
    1. Advertising

  3. Dinu

    Dinu Guest

    On Jul 31, 5:25 pm, "Peter Bucher [MVP]" <>
    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??
    Dinu, Jul 31, 2007
    #3
  4. Dinu

    Dinu Guest

    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
    Dinu, Jul 31, 2007
    #4
  5. Peter Bucher [MVP], Jul 31, 2007
    #5
  6. 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
    Peter Bucher [MVP], Jul 31, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mad Scientist Jr
    Replies:
    0
    Views:
    626
    Mad Scientist Jr
    Mar 22, 2006
  2. kevin
    Replies:
    11
    Views:
    5,783
    Andrew McDonagh
    Jan 8, 2005
  3. Wally Barnes
    Replies:
    3
    Views:
    511
    Wally Barnes
    Nov 20, 2008
  4. Sosuke

    Up casting and down casting

    Sosuke, Dec 20, 2009, in forum: C++
    Replies:
    2
    Views:
    550
    James Kanze
    Dec 20, 2009
  5. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    530
    Jonathan Wood
    Feb 2, 2010
Loading...

Share This Page