473,385 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

asp:buttons, access keys, underlining and submit


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>?

Feb 22 '06 #1
1 1832
<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/

Feb 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Zalek Bloom | last post by:
Hello, I am developing a simple ASP application with VBScript and Access database. I am testing it on my Win98SE machine using Personal Web Server. My machine is Celeron 2000 with 512Mb RAM. On...
3
by: D. Shane Fowlkes | last post by:
Sorry for the length of this post. I have created a rather complex form which has a header/line item (parent and child records) structure. It's for an intranet. A screenshot can be seen here: ...
2
by: Steven | last post by:
I need to prevent users from hitting a web control button twice, and can't find a way to do it. Someone must have a simple solution for this! If so, please help! I losing too much time on this..... ...
5
by: Randall Parker | last post by:
I'm looking at this web page: http://www.allasp.net/enterkey.aspx Where they say: Remember: * <asp:Button> controls render as <input type=submit value=xxx> html elements. *...
2
by: Kevin | last post by:
I have an ASP.Net site with a number of asp:button on it. When I run under localhost (Windows XP, VS 2003, Dotnet 1.1.4322), clicking these buttons works. However, transfering the site to a Windows...
5
by: Will | last post by:
- I know enough ASP and Access to be dangerous :) - I need to put up a data base on our web server with 3 related tables. - They will be accessed by a limited number of people. - Each user will...
3
Steve Kiss
by: Steve Kiss | last post by:
Hi. I have an asp page that has two buttons, both with onclick events. Unfortunately, when I press ENTER it's always the first event that gets fired. Any suggestions?
3
by: washed | last post by:
Here's my question... Much thanks if you can help... I have a form page with a ASP:imagebutton that calls a (VB sub click event) to calculate user input and displays the results on the page (that...
25
by: p byers | last post by:
Good Morning Folks I have a LAN Among the several connections to it are the following four devices: A MAXSTOR network Storage Device A PC running Microsoft Windows 2000 Server 5.0.2195 (SP4) A...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.