beginning page load immediately on postback with a long load time ?

Discussion in 'ASP .Net' started by Mad Scientist Jr, Jun 29, 2004.

  1. i have a dropdown control with autopostback=on that when selected,
    posts back and populates a second dropdown. the 2nd dropdown takes a
    while to load, giving the user time to start typing in other fields
    before the screen refreshes. i would like to disable any user input
    during this time.

    I was thinking if it was possible to force the browser to begin
    loading the page immediately that it would erase the controls that are
    there and the user would be forced to wait (wouldn't be able to press
    any buttons, type in any textboxes etc) for the page to refresh.

    I started playing around with Response.Buffer/Flush but it didn't
    work. Any ideas on if this is possible and if so how to get it to
    work?

    Thanks

    Sample code:

    Private Sub Dropdown1_SelectedIndexChanged(ByVal sender As
    System.Object, ByVal e As System.EventArgs) Handles
    cboBroker_Alpha.SelectedIndexChanged
    ' CLEAR PAGE SO USER DOESN'T HAVE TIME TO WAIT AROUND AND START
    TYPING IN OTHER CONTROLS
    Response.Buffer = True
    Response.Flush()
    (CODE THAT TAKES A LONG TIME TO RUN HERE...)
    Mad Scientist Jr, Jun 29, 2004
    #1
    1. Advertising

  2. "Mad Scientist Jr" <> wrote in message
    news:...
    > i have a dropdown control with autopostback=on that when selected,
    > posts back and populates a second dropdown. the 2nd dropdown takes a
    > while to load, giving the user time to start typing in other fields
    > before the screen refreshes. i would like to disable any user input
    > during this time.
    >
    > I was thinking if it was possible to force the browser to begin
    > loading the page immediately that it would erase the controls that are
    > there and the user would be forced to wait (wouldn't be able to press
    > any buttons, type in any textboxes etc) for the page to refresh.
    >
    > I started playing around with Response.Buffer/Flush but it didn't
    > work. Any ideas on if this is possible and if so how to get it to
    > work?


    The problem is something like this:

    1, User requests page.aspx
    2. Server sends back html for page.aspx, including your dropdown with
    autopostback on.
    3. User changes selection in dropdown.
    4. Page posts back to the server
    5. User starts typing into the html sent back in 2.
    6. Server sends back html for posted-back page.aspx, including your loaded
    second dropdown, overwriting whatever the user had typed.

    So you see, what you would need to do is disable the controls on the page
    just before the postback begins. When the new html comes back, it will come
    back with enabled controls.

    This will take a bit of JavaScript in the onchange event of the dropdown.
    That script would have to run through the DOM and set the disabled property
    of all relevant objects to true.

    Now, I can't get you an example. I needed to do this in a control once, and
    had a bit of trouble with it. Only certain objects in the DOM implement the
    disabled property. Also, in some cases, setting the disabled property will
    disable all contained objects, but sometimes it won't and you'll have to
    iterate into the child objects. Also, I seem to remember that under some
    circumstances, I couldn't entirely disable an anchor object, and had to
    screw with the URL instead.

    Of course, another option would be to follow one of the various strategies
    for producing a "Waiting..." page.
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jun 29, 2004
    #2
    1. Advertising

  3. Mad Scientist Jr

    bruce barker Guest

    you also have to control the timing of the disable to happen after postback
    as disabled fields are not posted by the browser. dropdown with autopostback
    also will have problems if the user uses arrow keys to access the dropdown
    values (tries to post on every selection)

    -- bruce (sqlwork.com)


    "John Saunders" <> wrote in message
    news:...
    > "Mad Scientist Jr" <> wrote in message
    > news:...
    > > i have a dropdown control with autopostback=on that when selected,
    > > posts back and populates a second dropdown. the 2nd dropdown takes a
    > > while to load, giving the user time to start typing in other fields
    > > before the screen refreshes. i would like to disable any user input
    > > during this time.
    > >
    > > I was thinking if it was possible to force the browser to begin
    > > loading the page immediately that it would erase the controls that are
    > > there and the user would be forced to wait (wouldn't be able to press
    > > any buttons, type in any textboxes etc) for the page to refresh.
    > >
    > > I started playing around with Response.Buffer/Flush but it didn't
    > > work. Any ideas on if this is possible and if so how to get it to
    > > work?

    >
    > The problem is something like this:
    >
    > 1, User requests page.aspx
    > 2. Server sends back html for page.aspx, including your dropdown with
    > autopostback on.
    > 3. User changes selection in dropdown.
    > 4. Page posts back to the server
    > 5. User starts typing into the html sent back in 2.
    > 6. Server sends back html for posted-back page.aspx, including your loaded
    > second dropdown, overwriting whatever the user had typed.
    >
    > So you see, what you would need to do is disable the controls on the page
    > just before the postback begins. When the new html comes back, it will

    come
    > back with enabled controls.
    >
    > This will take a bit of JavaScript in the onchange event of the dropdown.
    > That script would have to run through the DOM and set the disabled

    property
    > of all relevant objects to true.
    >
    > Now, I can't get you an example. I needed to do this in a control once,

    and
    > had a bit of trouble with it. Only certain objects in the DOM implement

    the
    > disabled property. Also, in some cases, setting the disabled property will
    > disable all contained objects, but sometimes it won't and you'll have to
    > iterate into the child objects. Also, I seem to remember that under some
    > circumstances, I couldn't entirely disable an anchor object, and had to
    > screw with the URL instead.
    >
    > Of course, another option would be to follow one of the various strategies
    > for producing a "Waiting..." page.
    > --
    > John Saunders
    > johnwsaundersiii at hotmail
    >
    >
    bruce barker, Jun 30, 2004
    #3
  4. >4. Page posts back to the server

    What I want to do is for the page to post some whitespace back to the
    server, say a single space character, so the page in the user's browser
    is temporarily blanked out, so they can't type anything. Then when the
    server is done processing, it sends the postback page. Is that possible?


    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Emma Gumbdough, Jun 30, 2004
    #4
  5. "Emma Gumbdough" <> wrote in message
    news:...
    > >4. Page posts back to the server

    >
    > What I want to do is for the page to post some whitespace back to the
    > server, say a single space character, so the page in the user's browser
    > is temporarily blanked out, so they can't type anything. Then when the
    > server is done processing, it sends the postback page. Is that possible?


    Actually, no, it doesn't even make sense. The "page", in the users browser,
    posts form data back to the server. The server then sends HTML back in
    response.

    See
    Indicating Progress
    http://msdn.microsoft.com/library/d...serverprogressfromaspnetclientapplication.asp
    for some examples on progress.
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jun 30, 2004
    #5
  6. Yes. And when the page posts back, the codebehind BEGINS rendering the
    postback page, and flushes the buffer (which would contain some
    whitespace or maybe the header). The client then has a partial response
    in their browser (this will probably appear as a blank screen) and thus
    cannot type in any fields until the entire page loads. The server then
    continues to process and sends the remaining response to the client, at
    which point they can type again.




    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Emma Gumbdough, Jun 30, 2004
    #6
  7. "Emma Gumbdough" <> wrote in message
    news:...
    > Yes. And when the page posts back, the codebehind BEGINS rendering the
    > postback page, and flushes the buffer (which would contain some
    > whitespace or maybe the header). The client then has a partial response
    > in their browser (this will probably appear as a blank screen) and thus
    > cannot type in any fields until the entire page loads. The server then
    > continues to process and sends the remaining response to the client, at
    > which point they can type again.


    I wouldn't count on TCP/IP to be deterministic, even in the presence of a
    Flush call. If you want to make sure they don't type anything, you need to
    handle it on the client. You don't even have control over how much time
    passes after the user changes selection in the dropdown and before Page_Load
    starts.
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jun 30, 2004
    #7
  8. I ended up just putting the slow dropdowns on a different screen.

    The 'waiting' page idea sounded good but how would it be implemented -
    as a popup? Can the main page be given a RegisterStartupScript or
    register client side script that would be able to automatically close
    the popup (assuming it is a child of that browser) upon completion of
    loading?

    >you also have to control the timing of the disable to happen after

    postback as disabled fields are not posted by the browser



    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Emma Gumbdough, Jun 30, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. roni
    Replies:
    1
    Views:
    647
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=
    Aug 30, 2005
  2. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    673
    Eric Sosman
    Jul 8, 2003
  3. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,184
    Peter Shaggy Haywood
    Sep 20, 2005
  4. Rajorshi  Biswas
    Replies:
    3
    Views:
    368
    Rajorshi Biswas
    Jul 20, 2006
  5. Jesse B.
    Replies:
    9
    Views:
    230
    Jesse B.
    Mar 27, 2010
Loading...

Share This Page