Solved

Button DropDown c#

Posted on 2011-03-21
3
362 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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