开发者

Displaying Asp.net AJAX Calendar Extender Two Ways

开发者 https://www.devze.com 2022-12-30 02:28 出处:网络
Is there a way to set up the calendar extender so that the calendar displays when the text box recieves focus AND when the when the element with th开发者_运维技巧e \"PopupButtonID\" is clicked? With m

Is there a way to set up the calendar extender so that the calendar displays when the text box recieves focus AND when the when the element with th开发者_运维技巧e "PopupButtonID" is clicked? With my current settings it seems to be one or the other.


It's a bit of an ugly way to do it, but you can do this if you're prepared to use two extenders.

<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 way the calendar will appear whether you focus on the textbox or click the imagebutton.


Not that I'm aware of; it's one or the other. The only way I can think of is set it to use the popup control, then add a JS event handler for the textbox focus, and manually find the calendar extender, and there may be a show() method so you could manually invoke the trigger potentially. Not 100% sure. To find out do:

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

Again, never done it, so not 100% sure.

HTH.


Use the CalendarExtender's show() method, 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"/>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号