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. Events with Master Pages

Events with Master Pages

Scheduled Pinned Locked Moved ASP.NET
questionhelp
8 Posts 2 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.
  • C Offline
    C Offline
    Chris McGlothen
    wrote on last edited by
    #1

    Hey all, I'm trying to get an application up and running using Master Pages and their content pages using events to check user input. The problem that I'm encountering is how and where to declare the events so they fire just within the page that is accessed and its master page. I've used events before but not with master pages, ie: all content pages are aspx pages. Is it necessary to create seperate classes to handle the interactivity with the events, and if so how do I interconnect them with the content pages? The data I've come across on Google is very generic so far and handles only one master page with one content page. I only have two master pages, but it is running me through the ringer trying to figure this out. I know that this jumbled question probably sounds like the ravings of a simpleton, but if y'all could give me a push in the right direction I would really appreciate it. Thanks in advance.:)


    An American football fan - Go Seahawks!
    I can't believe that the 49ers beat the Hawks twice :( Lil Turtle

    T 1 Reply Last reply
    0
    • C Chris McGlothen

      Hey all, I'm trying to get an application up and running using Master Pages and their content pages using events to check user input. The problem that I'm encountering is how and where to declare the events so they fire just within the page that is accessed and its master page. I've used events before but not with master pages, ie: all content pages are aspx pages. Is it necessary to create seperate classes to handle the interactivity with the events, and if so how do I interconnect them with the content pages? The data I've come across on Google is very generic so far and handles only one master page with one content page. I only have two master pages, but it is running me through the ringer trying to figure this out. I know that this jumbled question probably sounds like the ravings of a simpleton, but if y'all could give me a push in the right direction I would really appreciate it. Thanks in advance.:)


      An American football fan - Go Seahawks!
      I can't believe that the 49ers beat the Hawks twice :( Lil Turtle

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      To access master page controls from the content page do something like this. protected void Page_Load(object sender, EventArgs e) { this.Init += new EventHandler(Page_Init); } protected void Page_Init(object sender, EventArgs e) { DropDownList ddl = (DropDownList)this.Master.FindControl("ddl"); ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged); } protected void ddl_SelectedIndexChanged(object sender, EventArgs e) { //put code here }

      GameFly free trial

      C 1 Reply Last reply
      0
      • T ToddHileHoffer

        To access master page controls from the content page do something like this. protected void Page_Load(object sender, EventArgs e) { this.Init += new EventHandler(Page_Init); } protected void Page_Init(object sender, EventArgs e) { DropDownList ddl = (DropDownList)this.Master.FindControl("ddl"); ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged); } protected void ddl_SelectedIndexChanged(object sender, EventArgs e) { //put code here }

        GameFly free trial

        C Offline
        C Offline
        Chris McGlothen
        wrote on last edited by
        #3

        Does this mean that I declare the event delegate on the master page?


        An American football fan - Go Seahawks! Lil Turtle

        T 1 Reply Last reply
        0
        • C Chris McGlothen

          Does this mean that I declare the event delegate on the master page?


          An American football fan - Go Seahawks! Lil Turtle

          T Offline
          T Offline
          ToddHileHoffer
          wrote on last edited by
          #4

          No, thats not necessary. You just add the event in the content page.

          GameFly free trial

          C 1 Reply Last reply
          0
          • T ToddHileHoffer

            No, thats not necessary. You just add the event in the content page.

            GameFly free trial

            C Offline
            C Offline
            Chris McGlothen
            wrote on last edited by
            #5

            Before my next question let me first thank you for all the help you've given me thus far, I do appreciate it. When I've used events before I had to add classes that handled the event information ie: Custom data Classes, EventArgs, and Custom Handlers. Is this still necessary with the above declaration? I can provide code samples if it'd help.


            An American football fan - Go Seahawks! Lil Turtle

            T 1 Reply Last reply
            0
            • C Chris McGlothen

              Before my next question let me first thank you for all the help you've given me thus far, I do appreciate it. When I've used events before I had to add classes that handled the event information ie: Custom data Classes, EventArgs, and Custom Handlers. Is this still necessary with the above declaration? I can provide code samples if it'd help.


              An American football fan - Go Seahawks! Lil Turtle

              T Offline
              T Offline
              ToddHileHoffer
              wrote on last edited by
              #6

              You are attaching the delegate to the event with the += operator. Does that answer your question?

              GameFly free trial

              C 1 Reply Last reply
              0
              • T ToddHileHoffer

                You are attaching the delegate to the event with the += operator. Does that answer your question?

                GameFly free trial

                C Offline
                C Offline
                Chris McGlothen
                wrote on last edited by
                #7

                Yes it does thank you.


                An American football fan - Go Seahawks! Lil Turtle

                T 1 Reply Last reply
                0
                • C Chris McGlothen

                  Yes it does thank you.


                  An American football fan - Go Seahawks! Lil Turtle

                  T Offline
                  T Offline
                  ToddHileHoffer
                  wrote on last edited by
                  #8

                  no problem.

                  GameFly free trial

                  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