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. Page Methods and ASCX

Page Methods and ASCX

Scheduled Pinned Locked Moved ASP.NET
announcement
10 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.
  • M Offline
    M Offline
    Matt Cavanagh
    wrote on last edited by
    #1

    Hi. I have a situation where I need to use Page Methods instead of posts backs on an ASCX control. But I cant find a way that doesnt involve putting code in the main aspx page(which I cannot do due to specifics of the project). I also cannot create a web service. Basically each ascx control needs to be self containing and not call anything else. P.S. Update panels work for what I need, but are SLOW SLOW SLOW. Thanks

    Strive to be humble enough to take advice, and confident enough to do something about it.

    D N 2 Replies Last reply
    0
    • M Matt Cavanagh

      Hi. I have a situation where I need to use Page Methods instead of posts backs on an ASCX control. But I cant find a way that doesnt involve putting code in the main aspx page(which I cannot do due to specifics of the project). I also cannot create a web service. Basically each ascx control needs to be self containing and not call anything else. P.S. Update panels work for what I need, but are SLOW SLOW SLOW. Thanks

      Strive to be humble enough to take advice, and confident enough to do something about it.

      D Offline
      D Offline
      daveyerwin
      wrote on last edited by
      #2

      roguemat wrote:

      Hi. I have a situation where I need to use Page Methods instead of posts backs on an ASCX control

      Hi, I'm gonna guess you are talking about asp.net ajax.

      roguemat wrote:

      But I cant find a way that doesnt involve putting code in the main aspx page(which I cannot do due to specifics of the project).

      To do this you can use ScriptManager.GetCurrent(Page); if you have a ScriptManager on your page already.

      roguemat wrote:

      I also cannot create a web service. Basically each ascx control needs to be self containing and not call anything else.

      Well yeah they need to make a web request I guess.

      roguemat wrote:

      P.S. Update panels work for what I need, but are SLOW SLOW SLOW.

      Well update panels use what we call ajax so they are just as fast as any request made by browser. Did I guess any thing right ?

      N 1 Reply Last reply
      0
      • D daveyerwin

        roguemat wrote:

        Hi. I have a situation where I need to use Page Methods instead of posts backs on an ASCX control

        Hi, I'm gonna guess you are talking about asp.net ajax.

        roguemat wrote:

        But I cant find a way that doesnt involve putting code in the main aspx page(which I cannot do due to specifics of the project).

        To do this you can use ScriptManager.GetCurrent(Page); if you have a ScriptManager on your page already.

        roguemat wrote:

        I also cannot create a web service. Basically each ascx control needs to be self containing and not call anything else.

        Well yeah they need to make a web request I guess.

        roguemat wrote:

        P.S. Update panels work for what I need, but are SLOW SLOW SLOW.

        Well update panels use what we call ajax so they are just as fast as any request made by browser. Did I guess any thing right ?

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

        daveyerwin wrote:

        Did I guess any thing right ?

        Only the first one.

        daveyerwin wrote:

        To do this you can use ScriptManager.GetCurrent(Page);

        Has nothing to do with PageMethod

        daveyerwin wrote:

        Well yeah they need to make a web request I guess.

        I'll give you this one also just for stating the blatantly obvious.

        daveyerwin wrote:

        update panels use what we call ajax so they are just as fast

        An ASP.NET UpdatePanel still goes through the page life cycle so yes it can be slow. Making a direct out of band AJAX call is much faster


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

        D 1 Reply Last reply
        0
        • M Matt Cavanagh

          Hi. I have a situation where I need to use Page Methods instead of posts backs on an ASCX control. But I cant find a way that doesnt involve putting code in the main aspx page(which I cannot do due to specifics of the project). I also cannot create a web service. Basically each ascx control needs to be self containing and not call anything else. P.S. Update panels work for what I need, but are SLOW SLOW SLOW. Thanks

          Strive to be humble enough to take advice, and confident enough to do something about it.

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

          Try having a look here, http://www.chadscharf.com/index.php/2009/11/creating-a-page-method-scriptmethod-within-an-ascx-user-control-using-ajax-json-base-classes-and-reflection/[^] However, I would say in your situation creating a page that does nothing except act a host for the PageMethods would give you flexibility in your design.


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

          M 1 Reply Last reply
          0
          • N Not Active

            daveyerwin wrote:

            Did I guess any thing right ?

            Only the first one.

            daveyerwin wrote:

            To do this you can use ScriptManager.GetCurrent(Page);

            Has nothing to do with PageMethod

            daveyerwin wrote:

            Well yeah they need to make a web request I guess.

            I'll give you this one also just for stating the blatantly obvious.

            daveyerwin wrote:

            update panels use what we call ajax so they are just as fast

            An ASP.NET UpdatePanel still goes through the page life cycle so yes it can be slow. Making a direct out of band AJAX call is much faster


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

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

            Mark Nischalke wrote:

            daveyerwin wrote: To do this you can use ScriptManager.GetCurrent(Page); Has nothing to do with PageMethod

            thsi has to do with

            roguemat wrote:

            But I cant find a way that doesnt involve putting code in the main aspx

            Mark Nischalke wrote:

            An ASP.NET UpdatePanel still goes through the page life cycle so yes it can be slow. Making a direct out of band AJAX call is much faster

            The UpdatePanel control represents the nerve center of the server-centric programming model of ASP.NET AJAX. It lets you execute server-side code and return updated markup to the client browser. You may wonder how this differs from classic postbacks. The difference is in how the postback is implemented-instead of a full page refresh, the UpdatePanel control manages to send an out-of-band request for fresh markup and then update the DOM tree when the response is ready. from msdn When, in the page life cycle would this "direct out of band AJAX call" be made ? Oh yeah , thanks for the "blatantly obvious" I'll take it :) edited for formatting

            modified on Wednesday, April 21, 2010 11:53 PM

            N 1 Reply Last reply
            0
            • N Not Active

              Try having a look here, http://www.chadscharf.com/index.php/2009/11/creating-a-page-method-scriptmethod-within-an-ascx-user-control-using-ajax-json-base-classes-and-reflection/[^] However, I would say in your situation creating a page that does nothing except act a host for the PageMethods would give you flexibility in your design.


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

              M Offline
              M Offline
              Matt Cavanagh
              wrote on last edited by
              #6

              Thanks! Seems perfect.

              Strive to be humble enough to take advice, and confident enough to do something about it.

              1 Reply Last reply
              0
              • D daveyerwin

                Mark Nischalke wrote:

                daveyerwin wrote: To do this you can use ScriptManager.GetCurrent(Page); Has nothing to do with PageMethod

                thsi has to do with

                roguemat wrote:

                But I cant find a way that doesnt involve putting code in the main aspx

                Mark Nischalke wrote:

                An ASP.NET UpdatePanel still goes through the page life cycle so yes it can be slow. Making a direct out of band AJAX call is much faster

                The UpdatePanel control represents the nerve center of the server-centric programming model of ASP.NET AJAX. It lets you execute server-side code and return updated markup to the client browser. You may wonder how this differs from classic postbacks. The difference is in how the postback is implemented-instead of a full page refresh, the UpdatePanel control manages to send an out-of-band request for fresh markup and then update the DOM tree when the response is ready. from msdn When, in the page life cycle would this "direct out of band AJAX call" be made ? Oh yeah , thanks for the "blatantly obvious" I'll take it :) edited for formatting

                modified on Wednesday, April 21, 2010 11:53 PM

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

                Trace through the events that occur when an Update panel is used. From your MSDN lookup, "The difference is in how the postback is implemented". Postback is not eliminated, just modified. On the other hand a direct AJAX call skips it all. Using PageMethod is essentially creating a web service that is hosted by the page and thus skips all the overhead assocaited with UpdatePanel.


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

                D 1 Reply Last reply
                0
                • N Not Active

                  Trace through the events that occur when an Update panel is used. From your MSDN lookup, "The difference is in how the postback is implemented". Postback is not eliminated, just modified. On the other hand a direct AJAX call skips it all. Using PageMethod is essentially creating a web service that is hosted by the page and thus skips all the overhead assocaited with UpdatePanel.


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

                  D Offline
                  D Offline
                  daveyerwin
                  wrote on last edited by
                  #8

                  Mark Nischalke wrote:

                  The difference is in how the postback is implemented".

                  An update panel does "a direct AJAX call". (how can an indirect call be made ? ) Check and see if updating an update panel calls isPostBack.

                  Mark Nischalke wrote:

                  On the other hand a direct AJAX call skips it all.

                  In order for an ajax call to have an effect on the web page you will have to impliment in your own code that which was "skipped". PostBack is a microsoft invented term which can mean a regular http post request like you would submit to an aspx page or a webservice, it can also mean a direct ajax call. Definition of postback from webopedia ... A mechanism introduced in the Microsoft ASP.NET to allow the communication between client side and server side.

                  Mark Nischalke wrote:

                  Postback is not eliminated, just modified.

                  Here we see that by definition a direct ajax call is cetainly a "postback" which is not eleminated by direct ajax call , just modified. At the bottom of this top heavy pyramid is the XmlHttpRequest object or its activex equivelant. It is used by update panel and by direct ajax call.

                  N 1 Reply Last reply
                  0
                  • D daveyerwin

                    Mark Nischalke wrote:

                    The difference is in how the postback is implemented".

                    An update panel does "a direct AJAX call". (how can an indirect call be made ? ) Check and see if updating an update panel calls isPostBack.

                    Mark Nischalke wrote:

                    On the other hand a direct AJAX call skips it all.

                    In order for an ajax call to have an effect on the web page you will have to impliment in your own code that which was "skipped". PostBack is a microsoft invented term which can mean a regular http post request like you would submit to an aspx page or a webservice, it can also mean a direct ajax call. Definition of postback from webopedia ... A mechanism introduced in the Microsoft ASP.NET to allow the communication between client side and server side.

                    Mark Nischalke wrote:

                    Postback is not eliminated, just modified.

                    Here we see that by definition a direct ajax call is cetainly a "postback" which is not eleminated by direct ajax call , just modified. At the bottom of this top heavy pyramid is the XmlHttpRequest object or its activex equivelant. It is used by update panel and by direct ajax call.

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

                    Don't understand what points you are trying to make. We'll just leave it as a misunderstanding in terminology and processes.


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

                    D 1 Reply Last reply
                    0
                    • N Not Active

                      Don't understand what points you are trying to make. We'll just leave it as a misunderstanding in terminology and processes.


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

                      D Offline
                      D Offline
                      daveyerwin
                      wrote on last edited by
                      #10

                      Mark Nischalke wrote:

                      Don't understand what points you are trying to make. We'll just leave it as a misunderstanding in terminology and processes.

                      I will be more than happy to clear up any misunderstandibgs you may have :)

                      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