ASP.Net questions

  • Thread starter Thread starter Jeremy Ames
  • Start date Start date
J

Jeremy Ames

If you have a client-side script that catches an event for a control, and a
server-side script that catches the same event, which event will fire first?
The reason I ask is I want a button that will do some data validation on the
server, and possibly run some client script to open another window when the
validation fails.

I could be looking into this the wrong way. I am definately open to
suggestions, so any help that you can give would be greatly appreciated.

Thanks,

Jeremy Ames
 
The client goes first. If the client doesn't cancel the submit event, then
there is a post to the server, and the server runs.

It doesn't sound like you have client side validation. You have server side
validation, which should then generate a client side script, which would
open a new window in case of failure (this might be just calling some
predefined javascript function).

If you think about how web page work, the client makes a request, the server
processes it and sends a response. When you click on a button, the client
sends another request to the server. So the client has a chance to process
that button click event before sending the request to the server - but after
the request is sent, it is too late. The event is gone, and a brand new page
has been generated. So there is no way for the server to process the event,
and then the client. The closest you can do is have the server generate
client side script to make something else happen.
 
If I generate client side script, wouldn't it run every time the page is
reloaded after the script is added?

The client goes first. If the client doesn't cancel the submit event, then
there is a post to the server, and the server runs.

It doesn't sound like you have client side validation. You have server side
validation, which should then generate a client side script, which would
open a new window in case of failure (this might be just calling some
predefined javascript function).

If you think about how web page work, the client makes a request, the server
processes it and sends a response. When you click on a button, the client
sends another request to the server. So the client has a chance to process
that button click event before sending the request to the server - but after
the request is sent, it is too late. The event is gone, and a brand new page
has been generated. So there is no way for the server to process the event,
and then the client. The closest you can do is have the server generate
client side script to make something else happen.
 
Since the page is recreated on every single request, then no. It will only
be there when the page streams it down. The times it doesn't write it out -
it won't be there.
 
Could you give me an example of how to add the script to the page?

Since the page is recreated on every single request, then no. It will only
be there when the page streams it down. The times it doesn't write it out -
it won't be there.
 
Back
Top