Displaying Progress info to client while ServerSide code executes.

  • Thread starter Chris Tillotson
  • Start date
C

Chris Tillotson

Hello, I just wanted to suggest this as an idea and get feedback if it
is a lame. I had a simple challenge. In my app a client can upload a
file and it took a while and I wanted to indicate to the client that
something was happening. Not a true indicaition of status but just a
..gif letting the client know that "Something" was happening and also
remove the Submit button they just clicked so they wouldn't keep
clicking etc.

I saw several involved articles about multithreading etc. and this
seemed more than needed for my problem. My idea, which seems to work
is to create a custom validator with the ControlToValidate = "". This
causes the javascript function you place in the
ClientValidationFunction to always fire. This is where I hide the
panel(div) that shows the submit button and all other data entry
fields and then show another panel with an animated .gif showing
flying files etc.

The custom validator looks like this. You have to support a ServerSide
version too but just have both client and server pass back "true"
because you aren't really using them to validate but rather just to
fire a javascript method prior to posting.

As I said it works but can anyone see why this isn't a good idea to
do? Thanks in advance Chris.

//Custom Validator
<asp:customvalidator id="validAddItemBtn" ControlToValidate=""
Display="Dynamic" ErrorMessage="" OnServerValidate="ValidAddItem_SVR"
ClientValidationFunction="validAddItem"Runat="server"></asp:customvalidator>

//javascript
function validAddItem(source,args)
{
//hide data entry panel
document.all.BodyPanel.style.display = 'none';

//display 'wait' panel
document.all.WaitPanel.style.display = '';

//return true for validation
args.IsValid = true;

}
 
S

Steve C. Orr [MVP, MCSD]

C

Chris Tillotson

Good ideas. I tried puttting javascript code in the onclick event of my
<asp:imagebutton> control but kept getting an error. I suspect this was
due to the fact that their was a server side handler attached to the
onclick already. I guess I don't know how to have a single
<asp:imagebutton> object fire both a client and serverside call. The
onSubmit of the form may work. I will have to see how it interacts with
other validation controls that are present.
 

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,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top