Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > asp:buttons, access keys, underlining and submit

Reply
Thread Tools

asp:buttons, access keys, underlining and submit

 
 
Sarmatia@gmail.com
Guest
Posts: n/a
 
      02-22-2006

I had a page working. The user moves data around the page - to and from
different ListBoxes and could save the changes with a click of a
button. Sounds easy, but *that's* a whole other nightmare.

Nevertheless, it was working. The Submit button was an asp:button with
an OnClick server-side method. Easy-cheesy.

Enter in-house standards.

I need to add an access key and underline the letter on the button
signifying what it is.

No can do with asp:buttons. AccessKey, yes. Underline One letter, No.

But, many posts say (and I've searched for better solutions) to use
something like
<button id="btn1" runat="server" type="submit"><u>B</u>utton1</button>

Ok, but how does one capture that post/submit on the server side?

I tried the Page_Load event, but then that interferes with my
DropDownList SelectedIndexChanged event - meaning that and the Submit
both are post-backs but have different functions. One loads the data
for a selected item, while the other saves changes to the database.

why am I continually fighting ASP.Net, not to mention the IDE
continually screwing up my code formatting?

In short; how do I assign a server side function to handle the click
event of a <button runat="server"></button>?

 
Reply With Quote
 
 
 
 
Darren Kopp
Guest
Posts: n/a
 
      02-22-2006
<button id="mybutton" accessKey="h" type="button"
runat="server"><u>B</u>utton</button>.

if visual studio hasn't already, add this
protected System.Web.UI.HtmlControls.HtmlButton mybutton; // c#
protected WithEvents mybutton as System.Web.UI.HtmlControls.HtmlButton
'vb

now just add the event as you did with the asp:button.

// for c#
private void InitializeComponent()
{
this.mybutton.ServerClick += new
System.EventHandler(this.mybutton_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void mybutton_ServerClick(object sender, System.EventArgs e)
{
}

' for vb.net
Private Sub mybutton_ServerClick(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles mybutton.ServerClick
End Sub


If you are having trouble with interference in the Page_Load, make sure
you are having things happen at the right time, maybe something like
this would help.

// c#
if(!Page.IsPostBack)
{
// run code to show data
}

// vb.net
if not Page.IsPostBack
'run code to show data
end if

HTH,
Darren Kopp
http://blog.secudocs.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inline Underlining in XHTML Strict? Kelwin Delaunay HTML 18 09-16-2009 09:47 AM
Firefox and Underlining Joe Firefox 2 03-30-2006 02:22 AM
FF1.04 underlining urls Wygtya Firefox 3 06-16-2005 11:36 AM
Hyperlinks With No Underlining Gillian White HTML 14 06-07-2004 04:35 PM
underlining on websites =?Utf-8?B?a21uZXdidXJu?= Microsoft Certification 2 05-25-2004 05:31 PM



Advertisments