Solved

Button DropDown c#

Posted on 2011-03-21
3
343 Views
Last Modified: 2013-12-17
I am trying to create a button that allows the user to change how the button works once clicked.

I have two operations defined currently,

Mode1 and Mode 2

The Default would be Mode 1

And the text of the button would say Mode 1

When the user clicks the button while the button says Mode 1 then Mode 1's operations execute.

I am trying to have a dropdown that looks like it is attached to the button , and this drown down allows the user to change the ButtonMode.

need some help in trying to resolve this. Right now to keep my project moving I just put two buttons on the web form
0
Comment
Question by:jhacharya
3 Comments
 
LVL 2

Author Comment

by:jhacharya
ID: 35183973
i was trying to do something like this

    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
        onselectedindexchanged="DropDownList1_SelectedIndexChanged">
            <asp:Button ID="EditSingleFile"
                runat="server"
                Text="Edit File"
                OnClick="EditSingleFile_Click" />
            <asp:Button ID="EditAllFilesIncludeSubDir"
                runat="server"
                Text="Edit All Files Inc Sub-Directories"
                OnClick="EditAllFilesIncludeSubDir_Click" />
    </asp:DropDownList>

but this does not work
0
 
LVL 7

Accepted Solution

by:
nbove earned 500 total points
ID: 35184498
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
        onselectedindexchanged="DropDownList1_SelectedIndexChanged">      
</asp:DropDownList>
<asp:Button ID="EditSingleFile"
  runat="server"
  Text="Edit File"
  OnClick="EditSingleFile_Click"
  Visible="true" />
<asp:Button ID="EditAllFilesIncludeSubDir"
  runat="server"
  Text="Edit All Files Inc Sub-Directories"
  OnClick="EditAllFilesIncludeSubDir_Click"
  Visible="false" />

In the codebehind for the page:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {
  if(DrowDownList1.SelectedIndex == 0) {
    EditSingleFile.Visible = true;
    EditAllFilesIncludeSubDir.Visible = false;
  }
  else {
    EditSingleFile.Visible = false;
    EditAllFilesIncludeSubDir.Visible = true;
  }
}
0
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 35185728
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now