You can add javascript function by using the RegisterClientScriptBlock function, and you can add the attributes (the calls to this function) using the .attributes.add(key, string) of the control to which you want to add the attribute. example: in the page_load
event
RegisterClientScriptBlock("Alert", "<script Language='Javascript'>function showAlert(){alert('Hello from java function');}</script>")
Then, also in the page_load event in a button named BUTTON1:
BUTTON1.Attributes.add("onClick", "showAlert()")
Now when you run the page, you should see an alert every time you click on the button.. hope this helps, sivilian
sivilian
Contributor
6235 Points
1194 Posts
Re: How to use JavaScript with asp.net.
Dec 05, 2003 05:25 PM|LINK
RegisterClientScriptBlock("Alert", "<script Language='Javascript'>function showAlert(){alert('Hello from java function');}</script>")Then, also in the page_load event in a button named BUTTON1:BUTTON1.Attributes.add("onClick", "showAlert()")Now when you run the page, you should see an alert every time you click on the button.. hope this helps, sivilian