Yes, you can do that but you should add it during the Load event like this:
<%@ Page Language="VB" %>
<script runat="server">
Protected Sub Page_Load _
(ByVal sender As Object, ByVal e As System.EventArgs)
Button1.Attributes.Add _
("onclick", "DoClose();return false;")
End Sub
</script>
<script>
function DoClose()
{
alert('Routine here.');
}
</script>
<html>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
</form>
</body>
</html>
Ken
Microsoft MVP [ASP.NET]
"riga" <> wrote in message
news:C8AE1006-CF33-4CD9-B755-...
> Can I add a call to javascript function from Web Server Control?
> Like this:
>
> <asp:Button id="btnClear" OnClick="Clear();".....>
|