User control referencing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?SmFtZXMgUGFnZQ==?=

    User control referencing

    Hi all

    I have a user control - mycontrol.ascx with various controls within it.
    mycontrol.ascx is utilised in myPage.aspx

    I have a class (class1) to carry out various functions, subs etc.
    How do I go about setting the properties of the controls within
    mycontrol.ascx directly from class1

    Ideally what i'd like to do is various control property settings in class1
    when the myPage.aspx page load event fires - but for various reasons I don't
    want this done in the code behind of myPage.aspx or myControl.ascx -
    (myControl.ascx will be utilised across the site and the various controls
    within it will need their properties set depending on certain conditions that
    may arise)

    This sort of control referencing was very easy in access adp but I'm a bit
    bit lost here!!

    Any pointers - vb.net (if possible)

    Thanks

  • =?Utf-8?B?SmFtZXMgUGFnZQ==?=

    #2
    Re: User control referencing

    Thanks Richard

    How would i go about your suggestions? Do you have any examples?


    "Richard Coltrane" wrote:
    Hi James,
    >
    Not sure where your difficulty lies with this.
    >
    A user control is just a class, so if u want to set its properties from
    another class, simply send a reference to it, to that class and make sure it
    exposes its controls as public properties..... or design some interface to
    allow this to be done.
    >
    Better yet though i would go the other way. Send a class with the property
    values to the User Control and allow the usercontrol to set its own
    properties. Even if you have to design a third class to act as a property
    container i would still do it this way. Much cleaner.
    >
    Perhaps im misunderstandin g but id never send a UserControl to code class to
    have it propertes set. i.e. send presention tier into business logic tier
    for configuration. Yuk.
    >
    hth
    >
    >
    "James Page" <JamesPage@disc ussions.microso ft.comwrote in message
    news:0AEB40BE-C392-437B-945C-2C80AE1623D5@mi crosoft.com...
    Hi all

    I have a user control - mycontrol.ascx with various controls within it.
    mycontrol.ascx is utilised in myPage.aspx

    I have a class (class1) to carry out various functions, subs etc.
    How do I go about setting the properties of the controls within
    mycontrol.ascx directly from class1

    Ideally what i'd like to do is various control property settings in class1
    when the myPage.aspx page load event fires - but for various reasons I
    don't
    want this done in the code behind of myPage.aspx or myControl.ascx -
    (myControl.ascx will be utilised across the site and the various controls
    within it will need their properties set depending on certain conditions
    that
    may arise)

    This sort of control referencing was very easy in access adp but I'm a bit
    bit lost here!!

    Any pointers - vb.net (if possible)

    Thanks
    >
    >
    >

    Comment

    • =?Utf-8?B?SmFtZXMgUGFnZQ==?=

      #3
      Re: User control referencing

      Thanks again Richard

      Found exactly what I needed to know at MSDN specifically at:

      Represents an .ascx file, also known as a user control, requested from a server that hosts an ASP.NET Web application. The file must be called from a Web Forms page or a parser error will occur.


      Its all very clear now!

      "Richard Coltrane" wrote:
      Hi James,
      >
      Not sure where your difficulty lies with this.
      >
      A user control is just a class, so if u want to set its properties from
      another class, simply send a reference to it, to that class and make sure it
      exposes its controls as public properties..... or design some interface to
      allow this to be done.
      >
      Better yet though i would go the other way. Send a class with the property
      values to the User Control and allow the usercontrol to set its own
      properties. Even if you have to design a third class to act as a property
      container i would still do it this way. Much cleaner.
      >
      Perhaps im misunderstandin g but id never send a UserControl to code class to
      have it propertes set. i.e. send presention tier into business logic tier
      for configuration. Yuk.
      >
      hth
      >
      >
      "James Page" <JamesPage@disc ussions.microso ft.comwrote in message
      news:0AEB40BE-C392-437B-945C-2C80AE1623D5@mi crosoft.com...
      Hi all

      I have a user control - mycontrol.ascx with various controls within it.
      mycontrol.ascx is utilised in myPage.aspx

      I have a class (class1) to carry out various functions, subs etc.
      How do I go about setting the properties of the controls within
      mycontrol.ascx directly from class1

      Ideally what i'd like to do is various control property settings in class1
      when the myPage.aspx page load event fires - but for various reasons I
      don't
      want this done in the code behind of myPage.aspx or myControl.ascx -
      (myControl.ascx will be utilised across the site and the various controls
      within it will need their properties set depending on certain conditions
      that
      may arise)

      This sort of control referencing was very easy in access adp but I'm a bit
      bit lost here!!

      Any pointers - vb.net (if possible)

      Thanks
      >
      >
      >

      Comment

      Working...