Monday, February 14, 2005

[ASP.NET 2.0] Providing hotkeys in Label server control

Label server control in ASP.NET 2.0 has a new attribute by name "AccessKey". Hotkeys are assigned using this keyword. As you know if we want to access an hot key we would use ALT + "access key".

Label server control also has another new attribute by name "AssociatedControlId". Here we would specify the name of another control on this form where control needs to go on using the hotkeys set.

For instance,

Write the below code snippet in your aspx and run the app. On clicking "ALT + N" the focus would be set on the TextBox control.

AccessKey="N" AssociatedControlId="txtFirstname">First<u>n</u>ame

<asp:Textbox ID="txtFirstname" Runat="server"></asp:Textbox>

No comments: