Results 1 to 2 of 2

Thread: asp .net web control library + java script function?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2005
    Posts
    11

    asp .net web control library + java script function?

    I've got a web composite control library project and I would like to add a button which runs a java script function when it is clicked. i.e. "onclick"
    I'm not sure where/how to add the java function block. A web user control file i.e. ascx allows you to view the HTML section to add script however for a web control library the file is of type .vb.

    Any ideas?

  2. #2
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: asp .net web control library + java script function?

    This is how to add a onClick JS to a button.

    In the Page load event:
    VB Code:
    1. If Not IsPostBack Then
    2.    btnClickMe.Attributes.Add("onClick", "alert('Woof!');return false")
    3. End If
    The return false on the end means that clicking the button does NOT cause a postback to the server and therefore the VB.NET button click event doesn't fire.
    Woka

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width