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;
}
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;
}