Sign in to follow this  

[web] Javascript problem

This topic is 3488 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys this is a friend using boolean's account and i have a quick javascript question. So im using Visual Studio '05 to create this website in c# and i have code behind pages running all my server side stuff. I have created a login page with a button which has an OnClick event on the code behind page and ive completed all the database stuff to check the username, password etc. now my question is this: How do I put javascript on that button to check for errors client-side and then, if there are no errors, pass to the onclick event in the code behind? Thanks, Booleans friend.

Share this post


Link to post
Share on other sites
ZOMG!!1! Who are you and what have you done to Boolean??!




Anyway, assuming you're using ASP.NET, look into the validator controls for client-side and server side validation. Alternatively, you could insert some javascript code into the control at run-time.
It's been a while since I did web development with .NET, so perhaps there are more elegant solution by now.

Share this post


Link to post
Share on other sites
as far as I can remember (can't test it here), ASP has a OnClientClick property. Assign your javascript code as a string to that, and it should run. If your javascript code returns false, it will cancel the postback, otherwise it'll proceed to the serverside OnClick event as normal.

Something like that anyway. Never been a huge fan of ASP, and haven't used it for some months now. :)

Share this post


Link to post
Share on other sites
hey this is booleans friend ;)

yeah your both right but I decided to take the advice of Wanmaster and stick some simple .asp validation controls beside the login text fields, works a treat, thanks mate.

Share this post


Link to post
Share on other sites

This topic is 3488 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this