Mapping Asp.net AJAX Calendar Extender Two Ways

Is there a way to configure the calendar expander so that the calendar displays when the text box receives focus. And when when you click on an item named "PopupButtonID"? With my current settings, it seems one way or the other.

+4
source share
3 answers

This is a bit ugly way to do this, but you can do it if you are ready to use two extensions.

<asp:TextBox runat="server" ID="DateTextBox" /> <asp:ImageButton runat="server" ID="CalendarImageButton" ImageUrl="~/date_16x16.gif" /> <ajaxtoolkit:CalendarExtender runat="server" id="Extender1" TargetControlID="DateTextBox"/> <ajaxtoolkit:CalendarExtender runat="server" ID="Extender2" TargetControlID="DateTextBox" PopupButtonID="CalendarImageButton" /> 

This will display the calendar if you focus on the text field or click the image button.

+6
source

Not that I knew; it is one or the other. The only way I can think of is to set it to use a popup control, and then add a JS event handler to focus the text field and manually find the calendar expander, and there might be a show () method so that you can manually trigger the trigger potentially. Not 100% sure. To find out, follow these steps:

 function textboxFocus() { var c = $find("<%= calextenderid.ClientID %>"); //can use firebug to see if c.open method exists, or check for something else } 

Again, I never did this, so I'm not 100% sure.

NTN.

+2
source

Use the show () method of CalendarExtender, referencing it by BehaviorID:

 <asp:TextBox runat="server" ID="DateTextBox" /> <asp:ImageButton runat="server" ImageUrl="~/date_16x16.gif" OnClientClick="$find('Extender1').show();return false;" /> <ajaxtoolkit:CalendarExtenderrunat="server" id="Extender1" BehaviorID="Extender1" TargetControlID="DateTextBox"/> 
+2
source

Source: https://habr.com/ru/post/1309431/


All Articles