Solved

Button DropDown c#

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

948 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

21 Experts available now in Live!

Get 1:1 Help Now