How to call a JavaScript function when asp:button is clicked

December 8th, 2006 · No Comments

Email This Post Email This Post

Create an asp:button namely “button1″.

On codebehind page, add the following:

private void Page_Load(object sender, System.EventArgs e)
{
button1.Attributes.Add(“onclick”, “jsFunc()”);
}

in which “jsFunc” is the JavaScript function you define in aspx page. With this, whenever button1 is clicked, “jsFunc” is called at client side.

Related posts:

  1. Passing value after pressing “Add to Cart” button in DataList


Tags: Programming

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment

CommentLuv badge

© 2006–2010 Now Eating — Sitemap

Switch to our mobile site