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. how do i know which web controls sent the request.

how do i know which web controls sent the request.

Scheduled Pinned Locked Moved ASP.NET
databasequestion
5 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.
  • A Offline
    A Offline
    AndieDu
    wrote on last edited by
    #1

    Hi All, Is there a way to do this: if a request is from a manual item, then re-fetch the data from database, and if a request is from the other web controls, say link button, then do not re-fetch data from database. Thanks very much.

    K P 2 Replies Last reply
    0
    • A AndieDu

      Hi All, Is there a way to do this: if a request is from a manual item, then re-fetch the data from database, and if a request is from the other web controls, say link button, then do not re-fetch data from database. Thanks very much.

      K Offline
      K Offline
      Karthik A
      wrote on last edited by
      #2

      I guess you could use __EVENTTARGET to identify the control that caused the post-back. i.e. the control that sent the current request. http://forums.asp.net/t/1352215.aspx[^]

      Cheers, Karthik

      A 1 Reply Last reply
      0
      • K Karthik A

        I guess you could use __EVENTTARGET to identify the control that caused the post-back. i.e. the control that sent the current request. http://forums.asp.net/t/1352215.aspx[^]

        Cheers, Karthik

        A Offline
        A Offline
        AndieDu
        wrote on last edited by
        #3

        Thanks very much for your reply, and you did point me in the right direction Here is the trick: Request.Params["__EVENTTARGET"].contains("xx"); xx is the control name (it's obficates, but still humna readable, such as: ctl00$AccordionMenu1$ctl15$clb0). the "AccordionMenu1" is the name of a user control, but u can but the other controls too, e.g. link button etc.

        K 1 Reply Last reply
        0
        • A AndieDu

          Thanks very much for your reply, and you did point me in the right direction Here is the trick: Request.Params["__EVENTTARGET"].contains("xx"); xx is the control name (it's obficates, but still humna readable, such as: ctl00$AccordionMenu1$ctl15$clb0). the "AccordionMenu1" is the name of a user control, but u can but the other controls too, e.g. link button etc.

          K Offline
          K Offline
          Karthik A
          wrote on last edited by
          #4

          Great, you are welcome! And, hopefully you might know this, just in case, you could get this value "ctl00$AccordionMenu1$ctl15$clb0" using <accordion_id>.ClientID (AccordionMenu1.ClientID in code-behind) in the server side or using '<%= AccordionMenu1.ClientID %>' (for use in javascript)

          Cheers, Karthik

          1 Reply Last reply
          0
          • A AndieDu

            Hi All, Is there a way to do this: if a request is from a manual item, then re-fetch the data from database, and if a request is from the other web controls, say link button, then do not re-fetch data from database. Thanks very much.

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            If you are using postbacks, the simple way is to inspect the sender variable in your event handler. This identifies the control that actually triggered the postback. It really is that simple.

            I have CDO, it's OCD with the letters in the right order; just as they ruddy well should be

            Forgive your enemies - it messes with their heads

            My blog | My articles | MoXAML PowerToys | Onyx

            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