Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > <asp:Button id="btnClear" OnClick="Clear();"

Reply
Thread Tools

<asp:Button id="btnClear" OnClick="Clear();"

 
 
riga
Guest
Posts: n/a
 
      10-13-2005
Can I add a call to javascript function from Web Server Control?
Like this:

<asp:Button id="btnClear" OnClick="Clear();".....>
 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      10-15-2005
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();".....>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments