Solved

Button DropDown c#

Posted on 2011-03-21
3
372 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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:…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

630 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