Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox, with a dropdownextender. I want the dropdownextender to show the drop down list contents when the user clicks on an image button?

I can get the textbox and the dropdownextender to work properly (without using code behind).

What do I do on the ImageButton's client click to show the dropdown contents?


XML
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="DateTimePicker.ascx.cs"
    Inherits="DateTimePicker" %>
<%@ Register
    Assembly="AjaxControlToolkit"
    Namespace="AjaxControlToolkit"
    TagPrefix="ajaxToolkit" %>

<asp:TextBox runat="server" ID="dateText" Width="79px" />
<asp:ImageButton runat="Server" ID="Image1" ImageUrl="~/images/Calendar_scheduleHS.png"
    AlternateText="" EnableViewState="False" CausesValidation="false" />
<asp:ImageButton runat="Server" ID="ImageButton1" ImageUrl="~/images/time.png"
    AlternateText="" EnableViewState="False" CausesValidation="false" />
<asp:Panel id="hiddenIntervals" runat="server">
    <asp:DropDownList runat="server" ID="timeIntevals">
        <asp:ListItem>08:00</asp:ListItem>
        <asp:ListItem>08:15</asp:ListItem>
        <asp:ListItem>08:30</asp:ListItem>
        <asp:ListItem>08:45</asp:ListItem>
        <asp:ListItem>09:00</asp:ListItem>
        <asp:ListItem>09:15</asp:ListItem>
        <asp:ListItem>09:30</asp:ListItem>
        <asp:ListItem>09:40</asp:ListItem>
        <asp:ListItem>10:00</asp:ListItem>
    </asp:DropDownList>
</asp:Panel>
<ajaxToolkit:DropDownExtender DropDownControlID="hiddenIntervals" TargetControlID="dateText" runat="server" ID="timeExtender" Enabled="true"></ajaxToolkit:DropDownExtender>
<ajaxToolkit:CalendarExtender ID="calendarButtonExtender" runat="server" TargetControlID="dateText"
    PopupButtonID="Image1" />
<ajaxToolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server"
    TargetControlID="dateText" WatermarkText="dd/mm/yyy" WatermarkCssClass="watermarked" />
Posted
Updated 7-Feb-12 4:00am
v2
Comments
zyck 7-Feb-12 9:56am    
can you post the code
zyck 7-Feb-12 10:26am    
can you clarify your problem?
if clicking the image button will show the dropdown. is that your problem?

Hi,
From this we can't conclude anything, but I want to suggest you to use jquery datetimepicker plugin for your problem! It is fully configurable and easy to integrate into your code (one line of code only)! All details you can find here!
 
Share this answer
 
Yes, my question is how do I get the ImageButton click to show the dropdown list contents ?

I want to use the button to save the user from hovering and then clicking the arrow.
 
Share this answer
 
Try this Code

JavaScript
<script type="text/javascript">
  
function toggleImageBtn(elemID) {  
  
   var pnl = document.getElementById(elemID);  
  
   if (pnl.style.display == 'block' || pnl.style.display == '')  
      pnl.style.display = 'none';  
   else  
      pnl.style.display = 'block';  
  
   return;  
}  
</script>  


ASP.NET
<asp:imagebutton runat="Server" id="ImageButton1" onclientclick="toggleImageBtn('hiddenIntervals')" imageurl="~/images/time.png" alternatetext="" enableviewstate="False" causesvalidation="false" xmlns:asp="#unknown" />
 
Share this answer
 
Comments
zyck 7-Feb-12 10:48am    
please "vote" or "accept solution" if this will help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900