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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Access content page procedure from master page button

Access content page procedure from master page button

Scheduled Pinned Locked Moved ASP.NET
csharphelpquestion
7 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.
  • D Offline
    D Offline
    De_Novice
    wrote on last edited by
    #1

    Hi Gurus, This is the situation:- I have a master page (masterpage.master) that contains a save button (btn_save). There are 3 contentpages that inherit this master page, each content page needs to use the save button but use the procdure for the content page. How do I make this happen that when user is on contentpage1 and user clicks save button, the procedure to save for contentpage1 is executed. I am new to .net and have searched the web but in vain. Will appreciate any help. I am using Vb.net ,kindly reply with code / explanation in vb. Thanks

    N 1 Reply Last reply
    0
    • D De_Novice

      Hi Gurus, This is the situation:- I have a master page (masterpage.master) that contains a save button (btn_save). There are 3 contentpages that inherit this master page, each content page needs to use the save button but use the procdure for the content page. How do I make this happen that when user is on contentpage1 and user clicks save button, the procedure to save for contentpage1 is executed. I am new to .net and have searched the web but in vain. Will appreciate any help. I am using Vb.net ,kindly reply with code / explanation in vb. Thanks

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      You could create an event which the content page would subscribe to then handle the button click event on the master page and raise the event

      public EventHandler<EventArgs> Submit;

      public void OnSubmit(object sender, EventArgs e)
      {
      EventHandler<EventArgs> handler = Submit;
      if (handler != null)
      {
      handler(sender, e);
      }
      }

      In your content page

      public void OnInit(...)
      {
      ((MyMaster)Page.Master).Submit += new EventHandler<EventArgs>(OnSubmit);
      }

      public void OnSubmit(object sender, EventArgs e)
      {
      // Handle submit action
      }


      I know the language. I've read a book. - _Madmatt

      modified on Tuesday, March 22, 2011 1:56 PM

      D R 2 Replies Last reply
      0
      • N Not Active

        You could create an event which the content page would subscribe to then handle the button click event on the master page and raise the event

        public EventHandler<EventArgs> Submit;

        public void OnSubmit(object sender, EventArgs e)
        {
        EventHandler<EventArgs> handler = Submit;
        if (handler != null)
        {
        handler(sender, e);
        }
        }

        In your content page

        public void OnInit(...)
        {
        ((MyMaster)Page.Master).Submit += new EventHandler<EventArgs>(OnSubmit);
        }

        public void OnSubmit(object sender, EventArgs e)
        {
        // Handle submit action
        }


        I know the language. I've read a book. - _Madmatt

        modified on Tuesday, March 22, 2011 1:56 PM

        D Offline
        D Offline
        De_Novice
        wrote on last edited by
        #3

        I do not understand , where would you create the event in the code behind of master page? Could you give soe more explanation and codesnipped vb?

        N 1 Reply Last reply
        0
        • D De_Novice

          I do not understand , where would you create the event in the code behind of master page? Could you give soe more explanation and codesnipped vb?

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          The first snippet is in your master page, the second, as indicated, is in your content page. What more explaination do you require?


          I know the language. I've read a book. - _Madmatt

          D 1 Reply Last reply
          0
          • N Not Active

            The first snippet is in your master page, the second, as indicated, is in your content page. What more explaination do you require?


            I know the language. I've read a book. - _Madmatt

            D Offline
            D Offline
            De_Novice
            wrote on last edited by
            #5

            what will the EventArgs be? How does this work. Can you give me a working example? Thank you for your time.

            N 1 Reply Last reply
            0
            • D De_Novice

              what will the EventArgs be? How does this work. Can you give me a working example? Thank you for your time.

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              This is a working example. I understand you are a novice but you don't seem to have a base from which to understand this. There is nothing more I can explain if you don't understand basic event handling in .net. I would suggest you pick up a book on ASP.NET and work through it. Then, if you still don't understand how this works, come back and ask more questions.


              I know the language. I've read a book. - _Madmatt

              1 Reply Last reply
              0
              • N Not Active

                You could create an event which the content page would subscribe to then handle the button click event on the master page and raise the event

                public EventHandler<EventArgs> Submit;

                public void OnSubmit(object sender, EventArgs e)
                {
                EventHandler<EventArgs> handler = Submit;
                if (handler != null)
                {
                handler(sender, e);
                }
                }

                In your content page

                public void OnInit(...)
                {
                ((MyMaster)Page.Master).Submit += new EventHandler<EventArgs>(OnSubmit);
                }

                public void OnSubmit(object sender, EventArgs e)
                {
                // Handle submit action
                }


                I know the language. I've read a book. - _Madmatt

                modified on Tuesday, March 22, 2011 1:56 PM

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #7

                Hi Mark, I've a few licenses of ESET NOD32 to be given away (It's fully functional, free, no strings attached, and nothing expected in return), and I chose a few people whom I think are contributing on the programming forums regularly. If you'd like one of those licenses, drop me a line. You could write to me at rajesh AT indiamvps DOT net Regards, Rajesh.

                "Real men drive manual transmission" - Rajesh.

                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