[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Conditionally display Confirm Button

Posted on 2008-11-19
7
Medium Priority
?
809 Views
Last Modified: 2012-05-05
I am going to hook up a Submit button on one of my pages to the ConfirmButtonExtender.  This is fairly straightforward - however, I want to only display this Confirm Button if a certain value is selected in a DropDownList, otherwise I just want the submit to happen with no message.  Any ideas?
0
Comment
Question by:RAFUser
  • 2
  • 2
5 Comments
 
LVL 13

Expert Comment

by:sm394
ID: 22996064
something like that

<asp:DropDownList ID="DropDownList1" AutoPostBack="true" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                <asp:ListItem Text="Enabled">
                </asp:ListItem>
                <asp:ListItem Text="Disabled">
                </asp:ListItem>
            </asp:DropDownList>
            <asp:Button ID="btnSubmit" Visible="false" runat="server" Text="submit" />


===code behind
 protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DropDownList1.SelectedValue.Equals("Enabled"))
            {
                btnSubmit.Visible = true;
            }
            else
            {
                btnSubmit.Visible = false;
            }
        }
    }
0
 

Author Comment

by:RAFUser
ID: 22996092
Sorry, I think I mistyped what I want.

I want to only show the confirm message if a particular item in my DropDownList is selected.
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 2000 total points
ID: 22996257
You can put the droptdownlist, button, and the confirmbuttonextender in a UdpatePanel, then set ddl's autopost=True, then in the code-behind, the ddl's SelectedIndexChanged event handler, if the selectedValue is the value that requires no confirmation, then just set confirmbuttonextender.enabled = false, otherwise set it to Ture.
0
 

Author Comment

by:RAFUser
ID: 22996290
Prairie,
I am a beginner with AJAX in general, and haven't worked with an UpdatePanel before.  I will try your suggestion.
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22996313
Just let me know if you have trouble with it and need some examples.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

830 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