asp.net如何防止页面回发文快递网格

时间:2014-06-23 14:10:23

标签: c# jquery asp.net devexpress

我有一个asp.net页面,我有开发表格,当用户点击排序或分组我需要显示一个交战消息,如果你点击确定状态将失去和取消我需要进行排序或分组。

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">


<div class="legend legend-right">
    <div class="legend-item legend-item-normal">
    </div>
    <span>Normal</span>
    <div class="legend-item legend-item-normal" style="background-color: <%=this.SkillSetDraftChangedBackgroundColor%>!important;">
    </div>
    <span>Rating items which are Changed</span>
</div>
<span id="spanHanlder" ></span>
<asp:UpdatePanel ID="UPRequester" runat="server">
    <ContentTemplate>
        <asp:Label ID="LblResource" runat="server" Text=""></asp:Label>
        <asp:Panel runat="server" ID="PnlStatus" BorderWidth="1px" Height="33px" Width="400px" CssClass="PanelStatus">
            <cmacgm:Row ID="RowTrainingStatusTextBox" runat="Server" Label="Status :" Width="100%" PositionNextElement="Right" WidthLabel="10px" CssClass="RowStatus">
                <asp:TextBox runat="server" ID="TxtStatus" Width="80%" ReadOnly="true" Font-Bold="true" />
            </cmacgm:Row>
        </asp:Panel>
        <cmacgm:UserForm runat="server" ID="UserForm" />
        <cmacgm:Form runat="server" ID="FormSkillsRating" Title="Level of Qualification" FormHorizontalAlign="Center">
            <cmacgm:Row ID="RowSkillsRating" runat="server" Width="100%">
                <dxwgv:ASPxGridView ID="GvSkillsRating" runat="server"  ClientInstanceName="GvSkillsRating" AutoGenerateColumns="false" Width="100%" KeyFieldName="SkillSetId" OnHtmlRowCreated="GvSkillsRating_onHtmlRowCreated" OnDataBound="GvSkillsRating_OnDataBound" OnHtmlRowPrepared="GcSkillsRating_OnHtmlRowPrepared" OnCustomUnboundColumnData="GcSkillsRating_CustomUnboundColumnData">
                    <Columns>
                        <dxwgv:GridViewDataColumn Caption="Skill group id" FieldName="GroupId" Width="100px" Visible="false" />
                        <dxwgv:GridViewDataColumn Caption="Skill group" Visible="true" FieldName="GroupName" Width="400px" GroupIndex="0" Settings-AllowSort="False" />
                        <dxwgv:GridViewDataColumn Caption="Skill Set Id" FieldName="SkillSetId" Visible="false" />
                        <dxwgv:GridViewDataColumn Caption="Skill" Visible="true" FieldName="Title" Width="400px" Settings-AllowSort="False" HeaderStyle-CssClass="no-underline"/>
                        <dxwgv:GridViewDataColumn Caption="SkillRating" FieldName="RatingId" Visible="false" />
                        <dxwgv:GridViewDataColumn Caption="isAvaliableForResource" FieldName="AvaliableForResource" Visible="false" />
                        <dxwgv:GridViewDataColumn Caption="ChangedAfterValidation" FieldName="ChangedAfterValidation" Visible="false">
                        </dxwgv:GridViewDataColumn>
                        <dxwgv:GridViewDataTextColumn FieldName="groupdescription" UnboundType="Decimal" Visible="false">
                        </dxwgv:GridViewDataTextColumn>
                        <dxwgv:GridViewDataColumn Caption="Rating" HeaderStyle-CssClass="no-underline">
                            <DataItemTemplate>
                                <asp:DropDownList ID="DDLSkillRating" runat="server">
                                </asp:DropDownList>
                            </DataItemTemplate>
                        </dxwgv:GridViewDataColumn>
                        <dxwgv:GridViewDataColumn Caption="Reviewer Rating" Visible="true">
                            <DataItemTemplate>
                                <asp:DropDownList ID="DDLReview" runat="server">
                                </asp:DropDownList>
                            </DataItemTemplate>
                        </dxwgv:GridViewDataColumn>
                    </Columns>
                    <ClientSideEvents BeginCallback="function(s, e) {
                                                                    var answer = confirm('Warning!');
                                                                    if (answer) {
                                                                        isCancelCallback=false;
                                                                    }
                                                                    else {
                                                                        return ASPxClientUtils.PreventEvent(e);
                                                                    }}" />
                    <SettingsBehavior AllowSort="false" SortMode="Default"  AutoExpandAllGroups="true" />
                    <Settings ShowFilterRow="false" ShowFooter="True" ShowHeaderFilterButton="false" ShowGroupedColumns="true" />
                    <SettingsPager PageSize="100" />
                    <GroupSummary>
                        <dxwgv:ASPxSummaryItem FieldName="GroupId" SummaryType="Count" DisplayFormat="{0}" />
                    </GroupSummary>
                </dxwgv:ASPxGridView>
            </cmacgm:Row>
            <cmacgm:Row ID="Row2" runat="server" CssClass="rightbutton">
                <asp:Button ID="BtnSkillRatingSave" runat="server" Text="Save" ButtonType="Default" ValidationGroup="AnnualRatingValidationGroup" Width="80px" OnClick="BtnSkillRatingSave_Click" />
                <asp:Button ID="BtnSkillRatingSubmit" runat="server" Text="Submit" ButtonType="Default" ValidationGroup="AnnualRatingValidationGroup" Width="80px" OnClick="BtnSkillRatingSubmit_Click" />
                <asp:Button ID="BtnSkillRatingValidate" runat="server" Text="Validate" ButtonType="Default" ValidationGroup="AnnualRatingValidationGroup" Width="80px" OnClick="BtnSkillRatingValidate_Click" />
            </cmacgm:Row>
        </cmacgm:Form>
    </ContentTemplate>
</asp:UpdatePanel>

如果取消或任何更好的解决方案,我应该怎么做才能取消ajax帖子谢谢

var answer = confirm('Warning!');
                                                            if (answer) {
                                                                        isCancelCallback=false;
                                                                    }
                                                                    else {
                                                                        return ASPxClientUtils.PreventEvent(e);
                                                                    }}" />

感谢

2 个答案:

答案 0 :(得分:1)

为此,您需要处理gridView客户端ColumnGroupingColumnSorting事件。如果需要阻止回调,请将e.cancel参数设置为true。

答案 1 :(得分:0)

在ClientSideEvents中,您要取消对服务器使用的请求:

e.processOnServer = false;