我有一個ASP.NET 3.5頁面,其中包含一個包含信息行和自定義按鈕以改變其狀態的中繼器。asp:UpdateProgress在點擊中繼器內的可下載內容後永不消失
假設是這樣的
btn1 btn2 btn3 Id Title Description Status1 Status2
BTN1和BTN2用來改變STATUS1和2分別。
btn3重定向到發送可下載的MS-Word報告的自定義處理程序。這種情況發生時並未真正離開頁面。
中繼器是一個UpdatePanel裏面,所以我可以更新狀態,而無需重新加載整個頁面每次。
當我點擊BTN1或2,加載微調似乎像往常一樣,並在該過程完成時,淡出和狀態改變。
當我點擊btn3,裝載微調在那裏停留,從不出門,即使是在我完成我的下載。
會發生什麼情況?
處理代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net;
using System.IO;
using PublishVersionControlCore;
using System.Configuration;
namespace PublishVersionControlWebControl.Handler
{
public class WordFileHandler : IHttpAsyncHandler
{
private HttpContext _context;
private AsyncTaskDelegate del;
protected delegate void AsyncTaskDelegate(HttpContext context);
#region IHttpAsyncHandler Members
public WordFileHandler()
{
this.del = new AsyncTaskDelegate(ProcessRequest);
}
public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
{
// Store context
_context = context;
return del.BeginInvoke(context, cb, extraData);
}
public void EndProcessRequest(IAsyncResult result)
{
this.del.EndInvoke(result);
}
#endregion
#region IHttpHandler Members
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
HttpResponse resp = context.Response;
resp.Clear();
int workItemId = 0;
if (Int32.TryParse(context.Request.QueryString["wi"], out workItemId))
{
MemoryStream ms = null;
using (WorkItemReportService.ReportClient client = new WorkItemReportService.ReportClient())
{
byte[] resultFile = client.GenerateWorkReport(
new Uri(ConfigurationManager.AppSettings["serverUri"]),
workItemId,
ConfigurationManager.AppSettings["wordTemplate"]);
ms = new MemoryStream(resultFile);
}
resp.ContentType = "application/octet-stream";
resp.AddHeader("content-disposition", String.Format("attachment;filename=RelatorioSimples_WI-{0}.docx", workItemId));
resp.Buffer = true;
ms.WriteTo(resp.OutputStream);
resp.End();
}
}
#endregion
}
}
ItemCommand爲轉發:
if (e.CommandName.Equals("WordExport"))
{
string uri = HttpContext.Current.Request.RawUrl;
string url = string.Format("{0}/WordReport.dohx?wi={1}",
uri.Substring(0, uri.LastIndexOf("/")), wivdata.SystemID);
Response.Redirect(url);
}
aspx頁面(我粘貼這一切,因爲我沒有搞清楚什麼是相關的,什麼不是):
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="~/ListaDeAtividadesPage.aspx.cs"
MasterPageFile="~/_layouts/customapplication.master" Inherits="PublishVersionControlWebControl.ListaDeAtividadesPage, PublishVersionControlWebControl, Version=1.0.0.0, Culture=neutral, PublicKeyToken=78508f22b73cda2b" %>
<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<link rel='stylesheet' text='text/css' href='/_layouts/Extensions/Versioning/css/style.css' />
<script src="/_layouts/Extensions/Versioning/js/jquery.tools.min.js" type="text/javascript"></script>
<script src="/_layouts/Extensions/Versioning/js/jquery.corner.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderPageImage" runat="server">
<img width="145" height="54" alt="Dashboard" src="/_layouts/Microsoft.TeamFoundation/images/notes.png" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"
runat="server">
<asp:Literal ID="TitleContent" runat="server"></asp:Literal>
</asp:Content>
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<script type="text/javascript">
_spOriginalFormAction = document.forms[0].action;
_spSuppressFormOnSubmitWrapper = true;
</script>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updPanel">
<ProgressTemplate >
<div class="follower">
<asp:Image ID="imgUpdate" CssClass="follower" ImageUrl="/_layouts/Extensions/Versioning/img/ui/ajax-loader.gif"
runat="server" />
<span class="follower">Carregando...</span>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<div>
<asp:UpdatePanel ID="updPanel" runat="server">
<ContentTemplate>
<asp:Literal ID="tooltipScript" runat="server" />
<div class="buttonBar">
<hr style="color: #426DA8;" />
<asp:Button CssClass="specific" ID="btnUpdateWI" Text="Atualiza WIs da Lista" runat="server"
UseSubmitBehavior="false" />
<asp:Button CssClass="specific" ID="btnRelatorioScripts" Text="Relatório de Scripts/ZIPs"
runat="server" />
<asp:Button CssClass="specific" ID="Button1" Text="Relatório de Publicações" runat="server" />
<asp:Button CssClass="generic" ID="btnVolta" Text="Volta ao Menu de Versões" runat="server" />
<hr style="color: #426DA8;" />
</div>
<asp:Repeater ID="rptListaAtividades" runat="server">
<HeaderTemplate>
<asp:Label ID="comentarioHeader" runat="server"/>
<h3>
<b class="rollback">Rollback</b> | <b class="emteste">Em Teste</b> | <b class="aindanaoincluido">
Ainda não Incluído</b> | <b class="parcialmenteok">Atividade Parcialmente OK</b>
| <b class="todosok">Atividade OK em Todas as Lojas</b> | <b class="parcpublicado">Parcialmente Publicada</b> | <b class="publicado">Atividade
Publicada</b>
</h3>
</HeaderTemplate>
<ItemTemplate>
<div class="item" style="display: inline-block; font-size: 12px">
<asp:ImageButton ToolTip="Gerar Relatório Word" ImageUrl="/_layouts/Extensions/Versioning/img/wordexport.png"
CommandName="WordExport" ID="btnWordExport" CssClass="itembutton" runat="server" />
<asp:ImageButton ToolTip="Marcar como Rollback" ImageUrl="/_layouts/Extensions/Versioning/img/rollback.png"
CommandName="MarkAsRollback" ID="btnItemRollback" CssClass="itembutton" runat="server" />
<asp:ImageButton ToolTip="Esta atividade possui código. Clique para sinalizar como apenas procedure/config"
ImageUrl="/_layouts/Extensions/Versioning/img/code.png" CommandName="MarkAsProc"
ID="btnItemProc" CssClass="itembutton" runat="server" />
<asp:Image ToolTip="Esta atividade não possui scripts de banco/zips." ImageUrl="/_layouts/Extensions/Versioning/img/noscript.png"
runat="server" CssClass="itembutton" ID="btnItemScript" />
<asp:Label ID="labelWI" Text="" runat="server"></asp:Label>
<asp:Literal ID="tooltip" runat="server" />
<asp:Label ID="labelState" Text="" runat="server"></asp:Label>
<span style="color: #4A82CB">
<%# DataBinder.Eval(Container.DataItem, "SystemAssignedTo") %>
- </span><span style="color: Navy">
<%# DataBinder.Eval(Container.DataItem, "SystemTitle") %>
</span>
<asp:HiddenField ID="workItemID" runat="server" />
</div>
<hr class="item" noshade style="color: #4CBDCB; height: 2px; background-color: #4CBDCB" />
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
其他詳情:
- 它在WSS 3.0
- 一個佈局頁我不知道更新面板就是它應該是
謝謝,我的解決方案是渲染一個JavaScript來請求文件。 – 2012-01-30 12:56:14