我找到了阻止网页here的一部分的好例子。
但是我现在已经尝试了几个小时来使我的UserControl适应这个例子但没有任何进展。可能是因为我对JQuery和ASP.Net还不太熟悉。例如。我不明白prm.add_beginRequest
和prm.add_endRequest
做了什么以及这个PageRequestManager是什么。
所以我想问一下这里的专家,如果你能解决我的问题:
我有一个带有网格(telerik RadGrid)的ASP.Net UserControl。在顶部我有一个保存按钮('btnSave')。单击该按钮时,服务器将数据保存到文件。到现在为止还挺好。但同时我想用这个例子中的漂亮栏来阻止这个网格。
有人可以告诉我如何调整我的UserControl,以便在服务器准备好之前阻止网格(和按钮)吗?
到目前为止,这是我的ExcelGrid.ascx文件:
<%@ Control Language="C#" AutoEventWireup="True" Codebehind="ExcelGrid.ascx.cs" className="ExcelGrid" Inherits="WebResourceEditor.UI.Main.RightContent.ExcelGrid" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<link href="/Styles/Styles.css" rel="Stylesheet" />
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
var radGridId = "<%=mainDataGrid.ClientID %>";
</script>
</telerik:RadCodeBlock>
<style type="text/css">
html body span .rinSingle .riTextBox .RadInput .RadInput_Default
{
width: 100% !important;
}
</style>
<telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
<script src="/Scripts/script.js" type="text/javascript"></script>
<script src = "/Scripts/jquery.blockUI.js" type = "text/javascript"></script>
<telerik:RadScriptBlock runat="server" ID="RadScriptBlock2">
<script type="text/javascript">
function RowContextMenu(sender, eventArgs) {
var menu = window.$find("<%=RadMenu1.ClientID %>");
var evt = eventArgs.get_domEvent();
var index = eventArgs.get_gridDataItem().get_element().id.split("__")[1];
document.getElementById("<%=radGridClickedRowIndex.ClientID %>").value = index;
sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true);
menu.show(evt);
evt.cancelBubble = true;
evt.returnValue = false;
if (evt.stopPropagation) {
evt.stopPropagation();
evt.preventDefault();
}
}
function GridCreated(sender, args) {
var scrollArea = sender.GridDataDiv;
var parent = window.$get("gridContainer");
var gridLabel = window.$get("gridLabel");
var gridMenuBar = window.$get("gridMenuBar");
var gridHeader = sender.GridHeaderDiv;
scrollArea.style.height = parent.clientHeight - gridHeader.scrollHeight
- gridMenuBar.scrollHeight - gridLabel.scrollHeight - 1 + "px";
}
function BlockUI(elementID) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(function () {
$("#" + elementID).block({ message: '<table align = "center"><tr><td>' +
'<img src="/Images/loadingAnim.gif"/></td></tr></table>',
css: {},
overlayCSS: { backgroundColor: '#000000', opacity: 0.6, border: '3px solid #63B2EB'
}
});
});
prm.add_endRequest(function () {
$("#" + elementID).unblock();
});
}
$(document).ready(function () {
BlockUI("gridContainer");
$.blockUI.defaults.css = {};
});
</script>
</telerik:RadScriptBlock>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="mainDataGrid">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="mainDataGrid" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
<telerik:AjaxUpdatedControl ControlID="RadMenu1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadMenu1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="mainDataGrid" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
<telerik:AjaxUpdatedControl ControlID="RadMenu1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<asp:HiddenField ID="radGridClickedRowIndex" runat="server" />
<div id="gridContainer" style="height:100%;">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<div id="gridLabel">
<asp:Label ID="fileNameTextEdit" style="padding: 2px 5px;"
Text="No Project Folder or Resource File Group selected" runat="server" />
<br/>
</div>
<telerik:RadGrid ID="mainDataGrid" OnNeedDataSource="mainDataGrid_NeedDataSource" OnPreRender="RadGrid1_PreRender"
Skin="Default" OnItemDataBound="RadGrid1_ItemDataBound" OnColumnCreated="mainDataGrid_ColumnCreated"
AllowMultiRowEdit="true" EnableLinqExpressions="false"
OnItemCommand="RadGrid1_ItemCommand"
runat="server">
<MasterTableView EditMode="InPlace" CommandItemDisplay="Top"
DataKeyNames="FileGroup,Name">
<CommandItemTemplate>
<div id="gridMenuBar" style="padding: 5px 5px;">
<asp:LinkButton ID="btnSave" runat="server" CommandName="Save">
<img style="border:0px;vertical-align:middle;" alt="" src="/Images/RightContent/popupImages/image01.png" />Save in Database</asp:LinkButton>
<asp:LinkButton ID="btnCancel" runat="server" OnClientClick="DiscardChanges(this, event);"
CommandName="Discard Changes">
<img style="border:0px;vertical-align:middle;" alt="" src="/Images/icons/16/image25.png" />Discard Changes</asp:LinkButton>
</div>
</CommandItemTemplate>
<Columns>
<telerik:GridBoundColumn DataField="Name" HeaderText="Name" ReadOnly="true" />
</Columns>
</MasterTableView>
<ClientSettings>
<Scrolling AllowScroll="true" ScrollHeight="500px" UseStaticHeaders="true" />
<ClientEvents OnRowContextMenu="RowContextMenu"/>
<ClientEvents OnGridCreated="GridCreated" />
</ClientSettings>
</telerik:RadGrid>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<telerik:RadContextMenu ID="RadMenu1" runat="server" OnItemClick="RadMenu1_ItemClick"
OnClientItemClicking="RadMenu1_ItemClicking" EnableRoundedCorners="true" EnableShadows="true"
OnClientLoad="MenuLoad">
<Items>
<telerik:RadMenuItem Text="Save" AccessKey="S">
</telerik:RadMenuItem>
<telerik:RadMenuItem Text="Discard Changes" AccessKey="C">
</telerik:RadMenuItem>
</Items>
</telerik:RadContextMenu>