UpdatePanel回发

时间:2014-06-24 16:32:23

标签: c# asp.net updatepanel

我在我的模态中使用UpdatePanel,如您所见:

<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" 
                    aria-hidden="true">×</button>
            <h3 class="modal-title">Telefones</h3>
        </div>
        <asp:UpdatePanel runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <div class="modal-body">
                    <div class="row-fluid">
                        <div class="form-group">
                            <div class="row">
                                <div class="col-md-2">
                                    <label>DDD (*):</label>
                                    <input id="txtDDD" runat="server" 
                                           class="form-control ddd"
                                           placeholder="DDD" 
                                           title="Insira o ddd do telefone"
                                           required="required" tabindex="3" />
                                </div>
                                <div class="col-lg-6">
                                    <label>Número (*):</label>
                                    <input id="txtNumeroTelefone" runat="server" 
                                           class="form-control numeroTelefone"
                                           placeholder="Número do Telefone"
                                           title="Insira o número do telefone"
                                           required="required" tabindex="3" />
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="row">
                                <div class="col-lg-6">
                                    <label>Tipo (*):</label>
                                    <select id="ddlTipoTelefone" runat="server" 
                                            class="form-control" tabindex="2"
                                            title="Escolha o tipo do Telefone">
                                        <option value="Residencial">
                                                Residencial
                                        </option>
                                        <option value="Celular">Celular</option>
                                        <option value="Comercial">Comercial</option>
                                        <option value="Fax">Fax</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnAddTelefoneGrid" 
                                          EventName="click" />
            </Triggers>
        </asp:UpdatePanel>
        <div class="modal-footer">
            <asp:Button ID="btnAddTelefoneGrid" ClientIDMode="Static" runat="server" 
                        CssClass="btn btn-primary" Text="Adicionar" 
                        OnClick="btnAddTelefoneGrid_Click" />
            <button type="button" data-dismiss="modal" class="btn">Fechar</button>
        </div>
    </div>
</div>

我的问题是我的按钮btnAddTelefoneGrid正在触发一个Postback,导致验证标签(必需)在我的模态后面的窗体中触发。

我使用触发器调用后面的代码,但它无法正常工作。请帮忙!

1 个答案:

答案 0 :(得分:0)

希望我能正确理解你的问题。如果您不希望在单击btnAddTelefoneGrid时触发验证,则可以将此按钮的属性CausesValidation设置为false。如果仍然需要单击按钮进行验证,但不需要某些控件进行验证,则可以使用ValidationGroup属性