Javascript Popup window

P

Paul Krasucki

This is for a search page that takes parameters on one page, processes the
query, and displays them on another page.
I've got a javascript popup window on a button click event. When the user
clicks the button, the popup window opens, and the parent page goes on with
the query. No problem there. The problems comes in when one of my
validator's throws an error, then naturally the page does not post back
waiting for the page to valid. However, the button click event still
happens on the client side, so the popup window opens, saying processing
query..... How do I stop the javascript function from running if the page
is not valid? Anyone with any ideas, or alternate plans would be greatly
appreciated. Thank you.
 
E

Earl Teigrob

Could you use a normal asp button with postback and use the
Page.RegisterStartupScript to write the javascript to open the window in the
event handler only if the page is valid??? I use code like this for sending
conditional js/page error messages to the user based on event handler
conditional testing...

Earl
 
P

Paul Krasucki

That does sound like a plan. But it will be something I'll have to read up
on, but I've got the weekend to do that. I can still force a server side
post back from a standard asp button right, I probably just have to set the
runat="server" right? THank you for your help.
 
E

Earl Teigrob

Paul,

Yes, using a standard asp.net button control should work fine...It will post
back to the server where you will test for Page.IsValid and take action
based on the results. If you use this approch, you will not need to write
any javascript into the button itself (asp.net will add the js to generate a
post back, of course)

Earl
 
M

mikeb

Paul said:
This is for a search page that takes parameters on one page, processes the
query, and displays them on another page.
I've got a javascript popup window on a button click event. When the user
clicks the button, the popup window opens, and the parent page goes on with
the query. No problem there. The problems comes in when one of my
validator's throws an error, then naturally the page does not post back
waiting for the page to valid. However, the button click event still
happens on the client side, so the popup window opens, saying processing
query..... How do I stop the javascript function from running if the page
is not valid? Anyone with any ideas, or alternate plans would be greatly
appreciated. Thank you.

In your client side code you should check the Page_IsValid variable to
see if the page passed client-side validation.

For some details see the "Client-Side Validation for ASP.NET Server
Controls" .NEt Framework help file entry.

You may need to rework your script so that the client side validation
occurs before your click handler does its work (so the Page_IsValid
variable will be set correctly). To do this you may need to call the
client script function Page_ClientValidate().

See the .NET Framework help topics:

"Script Library for Validator Sample", and
"Client-Side Functionality in a Server Control"

for more details.

You should also look at the WebUIValidation.js client side script
library that ASP.NET uses to support client side validation. That file
is normally installed in:

c:\inetpub\wwwroot\aspnet_client\system_web\xxxxxx

where xxxxxx is a folder name that corresponds to the version of the
..NET runtime installed.
 
M

msnews.news.com

Thank you to everyone that has helped me with this. I have several ways to
approach this at this point, which is great. Thank you.
 

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,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top