Calling server side code from teh client...

J

Jerry Camel

Trying to implement the following:

Users is logging in
They enter theire username and password and click a login button
The page should then display an activity indicator (animated gif) and then
call the server side routine that autheticates the user.
When the page comes back, the activity indicator disappears and any error
messages show up, or the user is taken to the application page if they were
authenticated.

Using an imagebuttom serv control I can accomplish all of it except making
the animated gif appear before postback.
If I use a regular image, I can call script in the client to make the
animated gif appear, but then how do I call the server side code to
authenticate the client? I tried using Form1.submit, but I don't know how
to catch that on the server side. Any thoughts are appreciated. Thanks.

Jerry
 
R

Rob Schieber

Jerry said:
Trying to implement the following:

Users is logging in
They enter theire username and password and click a login button
The page should then display an activity indicator (animated gif) and then
call the server side routine that autheticates the user.
When the page comes back, the activity indicator disappears and any error
messages show up, or the user is taken to the application page if they were
authenticated.

Using an imagebuttom serv control I can accomplish all of it except making
the animated gif appear before postback.
If I use a regular image, I can call script in the client to make the
animated gif appear, but then how do I call the server side code to
authenticate the client? I tried using Form1.submit, but I don't know how
to catch that on the server side. Any thoughts are appreciated. Thanks.

Jerry

I would investigate AJAX (Async javascript and Xml)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/ASPNetSpicedAjax.asp
You would basically end up setting up a web service and doing everything
on the client.

You could also try looking using some kind of page hidden within an
IFRAME to make your post while you control the display on the main page.
 
S

S. Justin Gengo

Jerry,

I'm doing exactly that with the following code:

'---Preload the animated .gif
Page.RegisterStartupScript("PreLoad", "<script language=""javascript"">img1
= new Image();img1.src='Images/UI/loadgraphic.gif';</script>")
'---Attach the a javascript to the form's submit button that shows the gif
and still allows the button to submit.
SubmitButton.Attributes.Add("onclick", "document.all('" &
TotalLabel.ClientID & "').innerHTML = '<div align=""center"">Retrieving
Price<br><img src=""Images/UI/loadgraphic.gif""></div>';")

As long as the javascript doesn't have a "return false;" on the end the
button still submits.

Hope this helps.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
 
J

Jerry Camel

What I ended up doing is having the image in place with a hidden style
attribute. Then responding to the onsubmit event of the form and adjusting
the style of the image to visible. The form then submits itself as it
normally would. It's incredibly simple.

Sub Form1_onsubmit
Form1.imgActivity.style.visibility="visible"
End Sub

Don't hate because I use vbscript... But this was all it needed. The
submit button itself doesn't change because submitting the form causes this
event to occure before the actual submit.
I still have one little isse in that the gif appears but doesn't seem to
animate. Which it does normally... Not sure if that's because the submit
is happening so quickly...

Thanks for your insight. Always appreciate when people respond...

Jerry
 
B

Bruce Barker

animated gifs generally will not run during a postback. sites where you see
this work are generally polling (using a refresh), so the gif runs between
polls.

-- bruce (sqlwork.com)
 

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,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top