tags:

views:

1835

answers:

4

How to put underline for first letter for access key for ?

A: 

Tried the AccessKey attribute?

<asp:button id="Button1" runat="server" Text="Print" AccessKey="P" />

If it is really underlined is out of your control. The user agent (e.g. browser) is deciding that.

Tomalak
A: 

Putting the AccessKey attribute is to set the short cut key. But how the user knows that here P is the ShortCut key for this particular Button?

Nikita
They don't unless* You write it on the screen ("press P to click this button!!")* They have the Firefox web developer toolbar and click Information/Display Access Keys.Unfortunately access keys aren't very helpful in practice.
martin
+2  A: 

asp:buttons are output as html "input" tags with a type of "submit". The text displayed on them is output in the "value" attribute of the tag, and so cannot contain any styling or html. If you could get an asp:button to output as an html button then you could try something like:

<button id="mybutton" runat="server" onserverclick="myfunction">
<span style="text-decoration:underline;">P</span>rint</button>

and use a normal button event in your c# code:

protected void myfunction(object sender, EventArgs e)
{
 Response.Write("clicked");
}
Rob Bell
Just tested this in Visual Studio and it does the trick. I updated my post to change onclick to onserverclick.
Rob Bell
A: 

this is the button.does the above button fn . work for this?

Nikita
<asp:Button ID="btnSubmit" runat="server" CssClass="ButtonStyle" OnClick="btnSubmit_Click" Text="Submit" ValidationGroup="Submit" AccessKey="S" />
Nikita
<cc1:ConfirmButtonExtender ID="btnSubmit_cbeDelete" runat="server" ConfirmText="Are you sure to delete the record" Enabled="True" TargetControlID="btnSubmit">
Nikita
I couldn't say exactly as I'm not sure what a "ConfirmButtonExtender" is. The only way to say for sure is for you to give it a go.
Rob Bell