[Webinar] Streamline your web hosting managementRegister Today


ASP.net refresh WebForm before remainder of code runs

Posted on 2011-10-23
Medium Priority
Last Modified: 2012-05-12

On my ASP.net WebForm I have buttons in a GridView that when clicked change the background color of that row. In the final row, a lot of extra code is run after this and I need the user to see the color change and a message asking them to wait while the rest of the code runs. In the code below this is at the point marked
'Need above two lines to refresh webform before following code
If index = 19 Then
                    Me.Label_Finished.Text = "Please wait a moment........."

'Need above two lines to refresh webform before following code
                Call Load_Answers_Array(index, "Strongly Agree", 5, row.Cells(7).Text)

Open in new window

Question by:Murray Brown
LVL 96

Accepted Solution

Bob Learned earned 668 total points
ID: 37017480
You might be able to achieve something easier with AJAX UpdatePanel and UpdateProgress.

UpdateProgress Class
LVL 28

Assisted Solution

strickdd earned 668 total points
ID: 37018644
The reason this isn't working is simply that nothing gets sent back to the page until the full postback completes. This has to be done with javascript, AJAX is not required nor is an update panel. You merely need to call a javascript function that will set that rows color in the onclientclick of the button.
LVL 10

Assisted Solution

GlobaLevel earned 664 total points
ID: 37018655
in addition to the LearnedOne..

You could create a method that would be raised to handle the gridview.

this link seems to be doing the same thing with JS and gridview server control:

most soultions will follow a similar format:

Protected Sub Directory_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)  

if  e.Row.RowState <> ' last row then
end if

if  e.Row.RowState  = ' last row then
end if

end sub

see here for more  links:
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.


Author Comment

by:Murray Brown
ID: 37019052
can you not force the postback?
LVL 10

Expert Comment

ID: 37020648

Author Comment

by:Murray Brown
ID: 37020670
Thanks. What VB.net code would you use to do this
LVL 10

Expert Comment

ID: 37020815
you have to use javascript...

if you want a timed forced postback...you need to add a timer to your JS, then kick off the above...

i think form.submit() should work too...

Author Closing Comment

by:Murray Brown
ID: 37059111
Thanks for the help. Had hoped there would be a more simple way

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question