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. In a Usercontrol which control triggered postback event

In a Usercontrol which control triggered postback event

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

    In a ordinary web form Iam able to find out which control triggered postback event using Determinepostbackmode method. In a usercontrol i need to find out which control triggered postback event. I dont find any method called determinepostmode in usercontrol. Can anyone help out with this. Padvit

    M 1 Reply Last reply
    0
    • P padvit

      In a ordinary web form Iam able to find out which control triggered postback event using Determinepostbackmode method. In a usercontrol i need to find out which control triggered postback event. I dont find any method called determinepostmode in usercontrol. Can anyone help out with this. Padvit

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

      Hi there, The DeterminePostBackMode is a protected virtual method of the Page class, so you can call this method inside your web page which inherits from the Page class. However, in a user control you are only allowed to access the public properties and method of the Page class via the Page property of the control. If you want to use this method, you can simply create your own method which has the same logic with the help of the HttpContext object.

      private NameValueCollection ControlDeterminePostBackMode()
      {
      if (string.Compare(HttpContext.Current.Request.HttpMethod, "POST", false, CultureInfo.InvariantCulture) == 0)
      {
      return HttpContext.Current.Request.Form;
      }

      return HttpContext.Current.Request.QueryString;
      }

      For more information, see the Page.DeterminePostBackMode Method[^] Just curious, why do you need to do this as I saw a similar question which was already answered by Brian?

      P 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, The DeterminePostBackMode is a protected virtual method of the Page class, so you can call this method inside your web page which inherits from the Page class. However, in a user control you are only allowed to access the public properties and method of the Page class via the Page property of the control. If you want to use this method, you can simply create your own method which has the same logic with the help of the HttpContext object.

        private NameValueCollection ControlDeterminePostBackMode()
        {
        if (string.Compare(HttpContext.Current.Request.HttpMethod, "POST", false, CultureInfo.InvariantCulture) == 0)
        {
        return HttpContext.Current.Request.Form;
        }

        return HttpContext.Current.Request.QueryString;
        }

        For more information, see the Page.DeterminePostBackMode Method[^] Just curious, why do you need to do this as I saw a similar question which was already answered by Brian?

        P Offline
        P Offline
        padvit
        wrote on last edited by
        #3

        hi there Thank you very much. I always get answer from you for all of my question. One point for clarification. Do I need to declare this method in my usercontrol and call the same in pageload of the usercontrol. Iam on the busy schedule I didnt have time to got through questions. Padvit

        M 1 Reply Last reply
        0
        • P padvit

          hi there Thank you very much. I always get answer from you for all of my question. One point for clarification. Do I need to declare this method in my usercontrol and call the same in pageload of the usercontrol. Iam on the busy schedule I didnt have time to got through questions. Padvit

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

          You can declare that method as a normal method in your user control, then make a call in the Page_load event. Or you can put it in a common class which can be shared across controls.

          P 1 Reply Last reply
          0
          • M minhpc_bk

            You can declare that method as a normal method in your user control, then make a call in the Page_load event. Or you can put it in a common class which can be shared across controls.

            P Offline
            P Offline
            padvit
            wrote on last edited by
            #5

            Many thanks for the solution. I have been using it. it is absolutely working fine Padvit

            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