Solved

Button DropDown c#

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

18 Experts available now in Live!

Get 1:1 Help Now