asp:buttons, access keys, underlining and submit

Discussion in 'ASP .Net' started by Sarmatia@gmail.com, Feb 22, 2006.

  1. Guest

    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, 2006
    #1
    1. Advertising

  2. Darren Kopp Guest

    <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/
    Darren Kopp, Feb 22, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kelwin Delaunay

    Inline Underlining in XHTML Strict?

    Kelwin Delaunay, Apr 26, 2004, in forum: HTML
    Replies:
    18
    Views:
    21,894
    greatbigmassive
    Sep 16, 2009
  2. Gillian White

    Hyperlinks With No Underlining

    Gillian White, Jun 7, 2004, in forum: HTML
    Replies:
    14
    Views:
    951
    Karl Groves
    Jun 7, 2004
  3. bernhard

    underlining <sup>

    bernhard, Nov 2, 2005, in forum: HTML
    Replies:
    17
    Views:
    3,474
    Alan J. Flavell
    Nov 5, 2005
  4. DC
    Replies:
    2
    Views:
    7,118
  5. Replies:
    4
    Views:
    900
Loading...

Share This Page