Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. usercontrol get access to masterpage

usercontrol get access to masterpage

Scheduled Pinned Locked Moved ASP.NET
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Larza123
    wrote on last edited by
    #1

    I have an aspx page(X) that uses a masterpage(Y). The page(X) uses a usercontrol. I want to get access to the masterpageclass(Y) from the usercontrol. The reason for this is that I have some functionallity for errormessage alerts in my masterpage that I want to use from my usercontrol when something goes wrong. How can I do this? I know that I get the masterpage with this.parent.page.master but then I have to parse that into my masterpageclass but I can't access my masterpageclass. If I don't parse it I don't get access to the functions in the masterpage. Thanx!

    M 1 Reply Last reply
    0
    • L Larza123

      I have an aspx page(X) that uses a masterpage(Y). The page(X) uses a usercontrol. I want to get access to the masterpageclass(Y) from the usercontrol. The reason for this is that I have some functionallity for errormessage alerts in my masterpage that I want to use from my usercontrol when something goes wrong. How can I do this? I know that I get the masterpage with this.parent.page.master but then I have to parse that into my masterpageclass but I can't access my masterpageclass. If I don't parse it I don't get access to the functions in the masterpage. Thanx!

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, Your user control may not need to directly access the Master Page to use some utility functions in there. Instead, your content page which contains the user control will do that, here you can consider using the event/delegate pattern. By this I mean, you can define a custom event in the user control, and the content page will hook this event. Every time your user control wants to display error message, it simply raises the custom event to notify the content page which in turn calls the functions in the Master Page.

      I 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, Your user control may not need to directly access the Master Page to use some utility functions in there. Instead, your content page which contains the user control will do that, here you can consider using the event/delegate pattern. By this I mean, you can define a custom event in the user control, and the content page will hook this event. Every time your user control wants to display error message, it simply raises the custom event to notify the content page which in turn calls the functions in the Master Page.

        I Offline
        I Offline
        Ista
        wrote on last edited by
        #3

        minhpc_bk wrote:

        that, here you can consider using the event/delegate pattern.

        Wow min that the best advice I've seen given on this forum in a long, long, time. :-> 1 line of code equals many bugs. So don't write any!!

        M 1 Reply Last reply
        0
        • I Ista

          minhpc_bk wrote:

          that, here you can consider using the event/delegate pattern.

          Wow min that the best advice I've seen given on this forum in a long, long, time. :-> 1 line of code equals many bugs. So don't write any!!

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          As far as I can see, you're a fan of common patterns, Nick :)!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups