How do I call a server-side click event after client-side Javascript runs?

How do I call a server-side click event after client-side Javascript runs?

Post by John Peacoc » Wed, 27 Jun 2001 00:42:09


I have a Web form that I want to runs some checks on using JavaScript and if
the script passes, then I want to call the Click event of the button.

I have tried using the following code:
nextButton.Attributes.Add("onclick", "submitPage();");
nextButton.Click += new EventHandler(nextButton_Click);

This calls the JavaScript function (submitPage), but it calls the Click
event even if the script fails.  Is there a way to call the Server-side
click event from javascript?  Or, is there a way to disable the Click-Event?
I guess an alternative would be to just submit the form using javascript and
handle the post-back in the page load, but I was hoping that there is a more
elegant way to handle this.

 
 
 

How do I call a server-side click event after client-side Javascript runs?

Post by Hayato Irium » Wed, 27 Jun 2001 08:50:46


I think ...

> nextButton.Attributes.Add("onclick", "submitPage();");
should be...
> nextButton.Attributes.Add("onclick", "return submitPage();");



Quote:> I have a Web form that I want to runs some checks on using JavaScript and
if
> the script passes, then I want to call the Click event of the button.

> I have tried using the following code:
> nextButton.Attributes.Add("onclick", "submitPage();");
> nextButton.Click += new EventHandler(nextButton_Click);

> This calls the JavaScript function (submitPage), but it calls the Click
> event even if the script fails.  Is there a way to call the Server-side
> click event from javascript?  Or, is there a way to disable the
Click-Event?
> I guess an alternative would be to just submit the form using javascript
and
> handle the post-back in the page load, but I was hoping that there is a
more
> elegant way to handle this.


 
 
 

How do I call a server-side click event after client-side Javascript runs?

Post by Sandy R. Schor » Thu, 28 Jun 2001 03:28:47


Try this in the Page_Load event, when the page is loaded first time
(!IsPostBack):

   nextButton.Attributes["onClick"] = "return functionName('....')";

The function should return 'true' or 'false'.

Sandy R. Schorr  /  Viso-Data Computer AG


Quote:> I have a Web form that I want to runs some checks on using JavaScript and
if
> the script passes, then I want to call the Click event of the button.

> I have tried using the following code:
> nextButton.Attributes.Add("onclick", "submitPage();");
> nextButton.Click += new EventHandler(nextButton_Click);

> This calls the JavaScript function (submitPage), but it calls the Click
> event even if the script fails.  Is there a way to call the Server-side
> click event from javascript?  Or, is there a way to disable the
Click-Event?
> I guess an alternative would be to just submit the form using javascript
and
> handle the post-back in the page load, but I was hoping that there is a
more
> elegant way to handle this.

 
 
 

1. How could I call server-side function from client-side Javascript?

I have a web-form, a button and server-side function that have to run
when the button is clicked. Looks sipmle, but the web-form and the
function are located in one frame and the button is located in
another.

The only way I know to overcome the gap between two different frames
is JavaScript. But I don't know how could I call server-side function
from client-side Javascript.

Thank you for help.

Olga

2. It is so slooooow to have a FORM calls a report

3. How to call a server side-script when user clicks client-side menuitem ?

4. Books for a beginner.

5. client side javascript function - called from server side

6. programming

7. if a webform control or server control can handle both client-side and server-side events

8. Calling server-side function from client-side script

9. how to add client-side event handler to a server-side control?

10. Run client-side JavaScript when a asp:Button is clicked

11. Calling client side script from server side event

12. How do you refer to an HTML server-ran control in client-side javascript?