Multiple AutoPostBacks causes page to disappear

Discussion in 'ASP .Net Web Controls' started by Rick Lubanovic, Oct 19, 2003.

  1. All,

    I have a scenario that is causing a major problem in our
    ASP.Net Application. I have a page that contains an
    asp:textbox and an asp:dropdownlist control which are both
    set to AutoPostBack. If the text is changed within the
    textbox and the dropdownlist's arrow is clicked, the page
    will go blank and never repaint. The application is
    now "gone" until it is restarted. This only occurs in
    this exact sequence. If the textbox is changed and then
    the tab key is hit to go to the dropdownlist, all is
    well. It takes the text to be changed, then a click on
    the dropdown while the cursor is still in the textbox.

    I have tried a number of workarounds to solve this,
    including client side javascript in place of the multiple
    AutoPostBacks. Nothing I have tried has worked, I wonder
    if there is anything I can do to allow the interactivity I
    am looking for. Here is the issue:

    In this example, the ReturnDate is the textbox and the
    Hour and Minute controls are dropdownlists.

    Return Date: xx-xx-xxxx Hour: xx Minute: xx

    Time Updated: xxxxxxxxx By: xxxxxxxxxxxxx

    When either the return date is changed, or the time is
    changed, the Time Updated and By fields must be updated,
    and they are asp:label controls.

    We have built a number of forms with ASP.NET and this is
    the only showstopping issue that we have encountered. Any
    help would be greatly appreciated.

    Thanks,
    Rick Lubanovic
     
    Rick Lubanovic, Oct 19, 2003
    #1
    1. Advertising

  2. I have the same problem, but I can give one more clue, it hapens only in
    pages contained in a frame

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Eduardo Mendez, Oct 20, 2003
    #2
    1. Advertising

  3. Here is the answer I received from Microsoft Support:

    According to the case log, the problem is: Autopostpack
    causes page to disappear, and it only occurs on the
    specific page with the specific sequence.

    It looks to be a known issue of Internet Explorer 6.0. We
    can walk around this issue by adding a client script
    function to delay the postback of a second. Call the
    function in the OnChange event of the DropDownlist
    control. The code looks like:

    private void Page_Load(object sender, System.EventArgs e)
    {
    DropDownList1.Attributes.Add("onchange","testdelay()");
    WriteFunction(DropDownList1.UniqueID);
    // Put user code to initialize the page here
    }

    private void WriteFunction(string str)
    {
    Response.Write("<script language=\"jscript\">");
    Response.Write("function testdelay(){");
    Response.Write("setTimeout(\"__doPostBack('" + str + "','')
    \", 1);");
    Response.Write("}");
    Response.Write("</script>");
    }

    I tested the fix and it worked nicely.

    Rick

    >-----Original Message-----
    >I have the same problem, but I can give one more clue, it

    hapens only in
    >pages contained in a frame
    >
    >*** Sent via Developersdex http://www.developersdex.com

    ***
    >Don't just participate in USENET...get rewarded for it!
    >.
    >
     
    Rick Lubanovic, Oct 29, 2003
    #3
  4. Looking into the issue further, the fix did not work in
    all cases. Here is a better solution:

    Page_Load()
    {
    //
    // NOTE: This code must be executed on all calls to
    // Page_Load.
    //
    DelayPostBack();
    StartHours.Attributes.Add
    ( "onchange", "onChangeDelay(" + StartHours.UniqueID
    + ");//" );
    StartMinutes.Attributes.Add
    ( "onchange", "onChangeDelay(" + StartMinutes.UniqueID
    + ");//" );
    }

    private void DelayPostBack()
    {
    Response.Write("<script language=\"jscript\">");
    Response.Write("function onChangeDelay(str){");
    Response.Write("setTimeout(\"__doPostBack('\" +
    str + \"','')\", 1);");
    Response.Write("}");
    Response.Write("</script>");
    }

    That should do it.
    Rick

    >-----Original Message-----
    >Here is the answer I received from Microsoft Support:
    >
    >According to the case log, the problem is: Autopostpack
    >causes page to disappear, and it only occurs on the
    >specific page with the specific sequence.
    >
    >It looks to be a known issue of Internet Explorer 6.0. We
    >can walk around this issue by adding a client script
    >function to delay the postback of a second. Call the
    >function in the OnChange event of the DropDownlist
    >control. The code looks like:
    >
    >private void Page_Load(object sender, System.EventArgs e)
    >{
    >DropDownList1.Attributes.Add("onchange","testdelay()");
    >WriteFunction(DropDownList1.UniqueID);
    >// Put user code to initialize the page here
    >}
    >
    >private void WriteFunction(string str)
    >{
    >Response.Write("<script language=\"jscript\">");
    >Response.Write("function testdelay(){");
    >Response.Write("setTimeout(\"__doPostBack('" + str

    + "','')
    >\", 1);");
    >Response.Write("}");
    >Response.Write("</script>");
    >}
    >
    >I tested the fix and it worked nicely.
    >
    >Rick
    >
    >>-----Original Message-----
    >>I have the same problem, but I can give one more clue,

    it
    >hapens only in
    >>pages contained in a frame
    >>
    >>*** Sent via Developersdex http://www.developersdex.com

    >***
    >>Don't just participate in USENET...get rewarded for it!
    >>.
    >>

    >.
    >
     
    Rick Lubanovic, Nov 5, 2003
    #4
    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. Xavier Osa
    Replies:
    0
    Views:
    666
    Xavier Osa
    Jan 9, 2004
  2. Alex Shirley

    Textboxes and autopostbacks

    Alex Shirley, Jul 15, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    439
    bruce barker
    Jul 15, 2004
  3. gnewsgroup

    What causes session to disappear?

    gnewsgroup, Jan 18, 2008, in forum: ASP .Net
    Replies:
    8
    Views:
    575
    John Saunders [MVP]
    Jan 20, 2008
  4. daokfella

    Delaying autopostbacks on dropdownlists

    daokfella, Jun 3, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    395
    bruce barker
    Jun 3, 2008
  5. Larz
    Replies:
    5
    Views:
    537
    David Mark
    May 26, 2009
Loading...

Share This Page