How to: display page, post back, display again

G

Guest

Hi;

I would like to display a page then immediately cause a post back (the 1st
page will have a big "working..." on it, then in the post back do my query
which will take a couple of seconds, and then redisplay the page again.

What do I do in the first post back so the page is displayed to the user,
but I then get a post back again?
 
W

Walter Wang [MSFT]

Hi Dave,

Thank you for your post.

Based on my understanding, your question is how to cause another postback
upon page's first load. If I've misunderstood anything, please feel free to
post here.

You can do this by registering a startup script to cause the form to submit
again.

For example, use following WebForm:

<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Please
wait..."></asp:Label>&nbsp;</div>
</form>

Handle its Load event:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ClientScript.RegisterStartupScript(GetType(), "postback",
"document.forms[0].submit();", true);
} else
{
// simulate a lengthy operation
System.Threading.Thread.Sleep(5000);
// hide the "please wait" prompt
Label1.Visible = false;
}
}

Also, you may find following article useful:

#PleaseWaitButton ASP.NET Server Control
http://www.codeproject.com/aspnet/PleaseWaitButton.asp

Hope this helps. Please feel free to post here if anything is unclear.

Sincerely,
Walter Wang
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top