On a side note, if you wanted to have your on submit javascript stop the
submission of the form, you'd have to change the script to:

string script = "return doSomething();";

And have your function return true or false (not returning either true or
false acts just as if you returned true).

adam..



[EMAIL PROTECTED] on

                                                                                       
                                                
                                                                                       
                                                
               To:     "dotnet" <[EMAIL PROTECTED]>                            
                                                
               cc:                                                                     
                                                
               From:   [EMAIL PROTECTED]                                  
                                                
                                                                                       
                                                
                                                                                       
                                                
               Date:   09/30/2002 11:20 AM                                             
                                                
                       Please respond to "dotnet"                                      
                                                
               Subject:                                                  RE: Adding 
javascript onlcikc event to a button which already 
                       has one                                                         
                                                
                                                                                       
                                                





If all you want to do is execute some script on submission of the form, use
Page.RegisterOnSubmitStatement(string key, string script). The caveat to
this is that it won't work for the auto postback feature of ASP.NET... So
LinkButtons, autopostback drop down lists, etc won't fire this event, only
actual submit buttons will:

*** HTML ***
<script type="text/javascript">
function doSomething() {
      alert("hello");
}
</script>

*** Page_Load ***

string script = "doSomething();";
this.RegisterOnSubmitStatement("myscript", script);

*** Output ***

<form name="Form1" method="post" action="WebForm1.aspx" language
="javascript" onsubmit="doSomething();" id="Form1">

adam..

>I was trying to do client side stuff, that is the problem.
>
>Apparently, ASP.NET already uses client-side form.onsubmit and
>submit.onclick when it writes the code for webforms.  What I wanted to
>do was put my own function in the client script that uses submit.onclick
>or form.onsubmit.  But I can't figure out how to add my javascript to
>the code that .NET generates.




---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to %%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/







---
You are currently subscribed to dotnet as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/


Reply via email to