0
我的web應用程序:我點擊一個按鈕,這個按鈕調用一個web服務函數,這個函數創建一個文件(使用DocX dll)。我想下載這個剛剛通過網頁瀏覽器創建的文件,在網上下載一個類似的文件。 如何做到這一點?如何下載在asp.net中創建該文件的文件
我下面
代碼//點擊按鈕事件
$(frm_id+' #btn_eprt_tml')
.button()
.click(function(){
//eprt_tml
$.ajax({
type: "POST",
url: "JqueryFunction.aspx/eprt_tml",
data: "{ptcn_id:'"+ptcn_id+"'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function() {
alert("Completed");
},
error: function() {
alert("Not completed");
}
});
// eprt_tml功能
[System.Web.Services.WebMethod]
public static void eprt_tml(int ptcn_id)
{
DocX g_document;
try
{
// Store a global reference to the loaded document.
g_document = DocX.Load(@"D:\Project\CRM1\tml\tml_tpt.docx");
g_document = crt_from_tpl(DocX.Load(@"D:\Project\CRM1\tml\tml_tpt.docx"));
// Save all changes made to this template as Invoice_The_Happy_Builder.docx (We don't want to replace InvoiceTemplate.docx).
//g_document.Save();
g_document.SaveAs(@"D:\Project\CRM1\tml\Invoice_The_Happy_Builder.docx");
}
// The template 'Template.docx' does not exist, so create it.
catch (FileNotFoundException)
{
}
}
// crt_from_tpl功能
[System.Web.Services.WebMethod]
private static DocX crt_from_tpl(DocX template)
{
template.AddCustomProperty(new CustomProperty("static_title", "afdaslfjlk"));
template.AddCustomProperty(new CustomProperty("tmlname", "asdfasdfasf"));
template.AddCustomProperty(new CustomProperty("tmlcontent", "asdfasd"));
template.AddCustomProperty(new CustomProperty("ptcnname", "asdasdfsd"));
template.AddCustomProperty(new CustomProperty("ptcntitle", "asdfasdfsad"));
template.AddCustomProperty(new CustomProperty("coursename", "asdfsadsdf"));
return template;
}
你能解釋更多。我很開心。謝謝 – Hainlp 2012-02-08 08:17:01