簡體   English   中英

使用AsyncPostBackTrigger填充現有下拉列表,而不填充新的下拉列表

[英]Populating existing dropdownlist using AsyncPostBackTrigger, not populate a new dropdownlist

對於我的Web應用程序,我嘗試使用AsyncPostBackTrigger基於客戶端單擊日歷擴展程序的填充下拉列表(DDL)(我在vb.net的代碼隱藏中聲明了此內容以便從數據庫加載它)(因為我不希望頁面自動回發) 。 我有一個按鈕可以觸發選擇的日期,它確實可以填充DDL,但實際上並不是我想要的那樣。 除了在現有DDL中更新它之外,它還創建一個新的DDL。 我嘗試尋找解決方案,但沒有找到任何解決方案。 任何人都可以幫助我弄清楚為什么會發生這種情況以及如何解決此問題?

這是我的asp.net和javascript代碼


<asp:Label ID="label16" runat = "server" Text="Select the date"></asp:Label></td>
                                            <td id="Td29" style="width:290px;" runat="server">
                                            <asp:TextBox ID="tbPostingDt" runat="server" style ="width:174px;"></asp:TextBox>
                                            <asp:Button ID="ClickBtn" runat="server" Text="Click"  style="display:none" OnClick="ClickBtn_Click" />
                                                <asp:ImageButton ID="CalendarBtnPostingDt" runat="server" ImageUrl="~/Images/Calendar_scheduleHS.png" AlternateText="Click to display calendar"/>
                                                <cc1:CalendarExtender ID="calPost" runat="server" PopupButtonID="CalendarBtnPostingDt" 
                                                    TargetControlID="tbPostingDt" OnClientDateSelectionChanged="dateSelectionChanged" Format="dd-MMM-yyyy" Enabled="True"></cc1:CalendarExtender></td>

<asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
                                              <ContentTemplate>
                                                <asp:Label ID="label18" runat = "server" Text="Post Cycle No"></asp:Label></td>
                                            <td id="Td33" style="width:290px;" runat="server">
                                                <asp:DropDownList ID = "ddlPostCycleNo" runat = "server" style ="width:180px;">
                                                    <asp:ListItem>ALL</asp:ListItem>
                                                </asp:DropDownList> </td>
                                                </ContentTemplate>
                                                <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="ClickBtn" EventName="Click" />
                                                </Triggers>
                                                </asp:UpdatePanel>


    function dateSelectionChanged(sender, args) {
    var PostingDt = document.getElementById('<%= tbPostingDt.ClientID%>').value.trim();
    var clickButton = document.getElementById("<%= ClickBtn.ClientID %>");
    clickButton.click();
} 

沒關系,我已經知道了。 當用戶從日歷中選擇日期時,我在文本框中使用了ontextChanged,並刪除了OnClientDateSelectionChanged,觸發器和虛擬按鈕。 我保留了UpdatePanel,它按照我想要的方式工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM