popup
  • calendarextender
  • 2012-03-21 104 views 0 likes 
    0

    我想打開圖像按鈕onclick和文本框「txtstartdate」焦點上的日曆彈出。請幫忙。ajax日曆擴展器多個彈出式按鈕處理

    <asp:TextBox ID="txtStartDate" runat="server" Enabled="false" CssClass="dateBoxWidth TPRValue" Text='<%#DataBinder.Eval(Container.DataItem, "StartDate", "{0:ddd MMM dd, yyyy}")%>'></asp:TextBox> 
    
    <asp:ImageButton ID="imgBtnStartDate" runat="server" ImageUrl="~/Common/Images/Calendar.GIF" CausesValidation="false" ImageAlign="AbsMiddle" /> 
    
    <ajax:CalendarExtender ID="StartDateCalendar" TargetControlID="txtStartDate" PopupButtonID="imgBtnStartDate" runat="server" Format="ddd MMM dd, yyyy" OnClientDateSelectionChanged="onStartDateChanged"></ajax:CalendarExtender> 
    

    回答

    2

    試試這個:

    <asp:TextBox ID="txtStartDate" onFocus="javascript:document.getElementById('imgBtnStartDate').click();" runat="server" Enabled="false" CssClass="dateBoxWidth TPRValue" Text='<%#DataBinder.Eval(Container.DataItem, "StartDate", "{0:ddd MMM dd, yyyy}")%>'  ></asp:TextBox> 
    
    <asp:ImageButton ID="imgBtnStartDate" runat="server" ImageUrl="~/Common/Images/Calendar.GIF" CausesValidation="false" ImageAlign="AbsMiddle" /> 
    
    <ajax:CalendarExtender ID="StartDateCalendar" TargetControlID="txtStartDate" PopupButtonID="imgBtnStartDate" runat="server" Format="ddd MMM dd, yyyy" OnClientDateSelectionChanged="onStartDateChanged"></ajax:CalendarExtender> 
    

    在TextBox控件添加事件

    onFocus="javascript:document.getElementById('imgBtnStartDate').click();" 
    

    希望這解決了......

    如果你使用jQuery是更好這一個:

    onFocus="javascript:$('#imgBtnStartDate').click();" 
    
    相關問題