Multiple AutoPostBacks causes page to disappear

R

Rick Lubanovic

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
 
E

Eduardo Mendez

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

Rick Lubanovic

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
 
R

Rick Lubanovic

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top