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

Discussion in 'ASP .Net Web Controls' started by riga, Oct 13, 2005.

  1. riga

    riga Guest

    Can I add a call to javascript function from Web Server Control?
    Like this:

    <asp:Button id="btnClear" OnClick="Clear();".....>
     
    riga, Oct 13, 2005
    #1
    1. Advertising

  2. 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:...
    > Can I add a call to javascript function from Web Server Control?
    > Like this:
    >
    > <asp:Button id="btnClear" OnClick="Clear();".....>
     
    Ken Cox [Microsoft MVP], Oct 15, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David

    Response.Clear() doesn't clear

    David, Jan 31, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    1,067
    Mark Fitzpatrick
    Jan 31, 2008
  2. InvalidLastName

    Unrecognized element 'add' after <clear></clear>

    InvalidLastName, Feb 26, 2007, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    1,007
    Steven Cheng[MSFT]
    Mar 6, 2007
  3. Jake

    Clear textarea onclick of image

    Jake, Mar 18, 2005, in forum: Javascript
    Replies:
    3
    Views:
    151
    McKirahan
    Mar 18, 2005
  4. Replies:
    2
    Views:
    269
  5. Dr. Leff
    Replies:
    7
    Views:
    230
Loading...

Share This Page