Decrease Font Size
Increase Font Size
   BLOG

ASP-NET Confirm dialog box based on DropDownList selected value

by bryian 15. February 2010 13:30

ASP.NET Confirm dialog box based DropDownList selected value

ASP.NET JavaScript popup window basedon DropDownList selected value

Popup confirmation before ASP.NET Form Submit |

Add a JavaScript popup to an ASP.NET button |

Display Confirmation pop up window |

ASP.NET DropDownList Confirmation |

ASP.NET Adding JavaScript confirm to button based on DropDownList selected value |

Show JavaScript confirm message if DropDownList selected value equal

 

Requirement

User want to see a popup confirmation dialog box on LinkButton click, only if the DropDownList.SelectedValue == ?


See example below:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    <asp:DropDownList runat="server" ID="ddlTest">
        <asp:ListItem Selected="True">select</asp:ListItem>
        <asp:ListItem>a</asp:ListItem>
        <asp:ListItem>b</asp:ListItem>
        <asp:ListItem>c</asp:ListItem>
        <asp:ListItem>d</asp:ListItem>
        <asp:ListItem>e</asp:ListItem>   
    </asp:DropDownList>
    
    <asp:LinkButton ID="IsertButton"
                  runat="server"
                  Text="Insert" onclick="IsertButton_Click"
                  OnClientClick="return CheckIfZeroSelected();" />
   
    </div>
    </form>
    
  <script type="text/javascript">
      function Insert_Confirmation() {
          if (confirm("Are you certain that you want to insert with selected value 0?"))
              return true; else return false;
      }

      function CheckIfZeroSelected() {
          var selObj = document.getElementById('<%= ddlTest.ClientID %>');

          if (selObj.selectedIndex === 0) {
              return Insert_Confirmation();
          }    
      }
  </script>  
</body>
</html>

Tags: , ,

ASP.NET

Comments (12) -

1/19/2010 11:54:53 AM #

Catering Sydney

Good post...this is by far the best code I've seen on this topic on the internet.I really like to personally thank you and I look forward to reading your blog more and more..I love to visit her very often.....

Catering Sydney India

1/30/2010 6:26:44 PM #

ripped abs

I hope your blog and articles will keep on putting me on the right direction as long as possible! Thanks ---

ripped abs Turkey

1/30/2010 8:43:05 PM #

leslie

Great code. many thanks.

leslie United States

2/1/2010 9:46:47 PM #

cheap hotels in las vegas

Hai friends, I want to display a confirm messagbox with "ok" and "cancel" button. when i click ok it has to call a procedure to do deletion.

cheap hotels in las vegas United States

2/2/2010 12:40:08 PM #

df

hi..

df United States

2/7/2010 5:17:41 AM #

Acid Reflux Symptoms

I was very pleased to find this site. Thanks for this great read!  I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post.

Acid Reflux Symptoms Caribbean

2/14/2010 1:46:24 PM #

Abogado Laborista

Hi from Russia! Will it be possible for me to quote a post as part of your weblog with the link to you? I've tried emailing you regarding this problem but it appears i cant achieve you, please reply when have a moment, thanks.

Abogado Laborista France

2/15/2010 2:53:23 AM #

laser pointer

nice post.

laser pointer United States

2/25/2010 12:35:52 PM #

indonesia java international destination

you put the all great things which makes all people getting interested. but yes thats right, i agree. all you mention is make a sense. thanks

indonesia java international destination United States

3/8/2010 7:11:39 AM #

mobile banking software

This is really such an interesting and very knowledgeable post here you have submitted so that i think i like it very much. I think it can be very beneficial for most of the people.

mobile banking software United States

3/16/2010 1:36:29 AM #

William

I've been trying to find a good forum on asp.net dropdownlist confirmation and related material. Thanks for putting this up.
Take care

William Bolivia

4/27/2010 5:33:14 AM #

Lorrie Guion

great code helped me a lot since i am just beginning....
i will be following up on your blog soon!

Lorrie Guion United States

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading