Monday, May 23, 2011

Define Access Key In button control

Flickr Tags: ,

If you want to underline and define the access key in just like you define in windows application , use the html button element. To produce the same behavior as an Button control. I set the runat attribute to "server" and use the onclick event to call javascript and onServerClick event to call a server side method.

Here is the code for the page,

<form id="form1" runat="server">

<button id="hbutton1" runat="server" type="submit" accesskey="A" onserverclick="hbutton1_Click" onclick="alert('test');"><u>A</u>dd</button>



protected void hbutton1_Click(object sender, EventArgs e)


           Response.Write("hbutton clicked");


When, the page is run, a button is generated with text "Add". When clicked, at first an alert message is shown and then the page postbacks.

1 comment:

PDF Arabic watermark using MVC and iTextSharp

PDF full page Arabic watermark using MVC and iTextSharp Download :  Source Code Most of the time we have requirement to  gen...