简体   繁体   English

重新加载按钮单击

[英]reload on button click in

Here is my aspx: 这是我的aspx:

<asp:Panel ID="pnl_updateClinicVisit" runat="server" CssClass="modalPopupClinicVisitEntry2" DefaultButton="bt_editClinicVisit_submit"  Style="display:none">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Button AutoPostBack="false" UseSubmitBehavior="false" ID="AddMedicationChange" ClientIdMode="Static" runat="server" Text="Add Med Change" OnClick="AddMedicationChange_Click" />
            <asp:Panel ID="AddNewMedicationPanel" runat="server">
                <asp:TextBox ID="NewDrugName" OnTextChanged="NewDrugName_TextChanged" runat="server"></asp:TextBox>
                <asp:AutoCompleteExtender ID="NewDrugNameAutoCompleteExtender"
                    runat="server"
                    TargetControlID="NewDrugName"
                    MinimumPrefixLength="1"
                    EnableCaching="false"
                    CompletionSetCount="1"
                    CompletionInterval="500"
                    ServiceMethod="GetDrugs">
                </asp:AutoCompleteExtender>
                <asp:DropDownList OnSelectedIndexChanged="NewDrugChange_SelectedIndexChanged" ID="NewDrugChange" runat="server">
                    <asp:ListItem>Drug +</asp:ListItem>
                    <asp:ListItem>Drug -</asp:ListItem>
                    <asp:ListItem>Dose ↑</asp:ListItem>
                    <asp:ListItem>Dose ↓</asp:ListItem>
                </asp:DropDownList>
                <asp:Button AutoPostBack="false" UseSubmitBehavior="false" ID="SubmitMedChange" runat="server" Text="Add to Visit" OnClick="SubmitMedicationChange_Click" />
            </asp:Panel>
            <asp:ModalPopupExtender ID="updateClinicModalPopupExtender" runat="server" TargetControlID="bt_editClinicVisit_dummy"
                PopupControlID="pnl_updateClinicVisit" CancelControlID="bt_editClinicVisit_cancel"
                DropShadow="true" BackgroundCssClass="modalBackground" />
        </ContentTemplate>
    </asp:UpdatePanel>          
 </asp:Panel> 

For some reason my page is reloading when I click the "AddnewMdication" and "SubmitMedChange" buttons. 由于某些原因,当我单击“ AddnewMdication”和“ SubmitMedChange”按钮时,页面正在重新加载。 When I have the AutoPostBack=false UseSubmitBehavior=false , the events fire and then the page reloads. 当我有AutoPostBack=false UseSubmitBehavior=false ,将触发事件,然后重新加载页面。 If I don't have these attributes then the page reloads before the events even fire. 如果我没有这些属性,那么页面将在事件发生之前重新加载。 How do I get AJAX functionality within this modal? 如何在此模式下获得AJAX功能?

Try setting your Button s as an AsyncPostBackTrigger . 尝试将Button设置为AsyncPostBackTrigger You can do this by adding in the Triggers section and declaring the UpdatePanel as a conditional update. 您可以通过在“ Triggers部分添加并声明UpdatePanel作为条件更新来完成此操作。

For example 例如

<asp:UpdatePanel ID="UpdatePanel1" runat="server"
    UpdateMode="Conditional">
    <Triggers>        
        <asp:AsyncPostBackTrigger ControlID="AddMedicationChange" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="SubmitMedChange" EventName="Click" />
    </Triggers>    
    <ContentTemplate>        
        <%-- Your code here --%>
    </ContentTemplate>
</asp:UpdatePanel>

What this should do is to explicitly declare that those two buttons as being Async. 这应该做的是将这两个按钮明确声明为异步。

If this doesn't work, will you please post the relevant code to your two button OnClick events? 如果这不起作用,请您将相关代码发布到两个按钮的OnClick事件中? AddMedicationChange_Click and SubmitMedicationChange_Click AddMedicationChange_ClickSubmitMedicationChange_Click

If you try to interact with controls outside of the UpdatePanel in your code-behind during an asyncpostback, odd things can start to happen. 如果在asyncpostback期间尝试与代码背后的UpdatePanel之外的控件进行交互,则可能会发生奇怪的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM