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. Firing a button_click event within a button_click event

Firing a button_click event within a button_click event

Scheduled Pinned Locked Moved ASP.NET
help
7 Posts 4 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.
  • G Offline
    G Offline
    gauthee
    wrote on last edited by
    #1

    Hi, I have two buttons btn a and b. Now, when i click btn b the logic written in btn a should be executed first and then btn b logic should be executed. Could anyone kindly help!

    Gautham

    B 1 Reply Last reply
    0
    • G gauthee

      Hi, I have two buttons btn a and b. Now, when i click btn b the logic written in btn a should be executed first and then btn b logic should be executed. Could anyone kindly help!

      Gautham

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      protected void btnB_Click(object sender, EventArgs e) { btnA_Click(this,e); }


      I Love SQL

      G 1 Reply Last reply
      0
      • B Blue_Boy

        protected void btnB_Click(object sender, EventArgs e) { btnA_Click(this,e); }


        I Love SQL

        G Offline
        G Offline
        gauthee
        wrote on last edited by
        #3

        Thanks!! What if my button a is in page1.aspx and button b is in page2.aspx?

        Gautham

        A P 2 Replies Last reply
        0
        • G gauthee

          Thanks!! What if my button a is in page1.aspx and button b is in page2.aspx?

          Gautham

          A Offline
          A Offline
          anj1983
          wrote on last edited by
          #4

          Create an instance of the page2.aspx and make the event of button b public and call the event from page1.aspx. I think this should work

          B 1 Reply Last reply
          0
          • A anj1983

            Create an instance of the page2.aspx and make the event of button b public and call the event from page1.aspx. I think this should work

            B Offline
            B Offline
            Blue_Boy
            wrote on last edited by
            #5

            I don't this that should works, if can you do it plz let us know how come.


            I Love SQL

            1 Reply Last reply
            0
            • G gauthee

              Thanks!! What if my button a is in page1.aspx and button b is in page2.aspx?

              Gautham

              P Offline
              P Offline
              Paddy Boyd
              wrote on last edited by
              #6

              Why not extract the logic from the button b click event and stick it in method in a class and then call the same method from both buttons. Slightly neater solution.

              G 1 Reply Last reply
              0
              • P Paddy Boyd

                Why not extract the logic from the button b click event and stick it in method in a class and then call the same method from both buttons. Slightly neater solution.

                G Offline
                G Offline
                gauthee
                wrote on last edited by
                #7

                Tried the same way, its correct however the requirement is that we have a textbox which we would some manipulations, so when we go the other page i need this text box and again send back again to the method for manipulations!!! sounds really weird!!! What is the best solution?

                Gautham

                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