如何在将文件内容上传到sql server数据库时显示更新进度? [英] How to show update progress while uploading file content to sql server database?
本文介绍了如何在将文件内容上传到sql server数据库时显示更新进度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨先生,
告诉我在将文件内容上传到sql server数据库时显示更新进度的步骤。我在excel文件中有
40,000条记录,我将记录上传到数据库,我需要在将记录上传到数据库时显示更新进度
,其工作正常,但我无法查看更新进度。
我附上了代码以获取更多详细信息。请给我解决这个问题的方法。
Homes.aspx:
**************
< asp:ScriptManager ID = ScriptManager1 runat = server >
< / asp: ScriptManager >
< br / >
< br / >
< br / > ;
< br / >
< asp:UpdatePanel ID = UpdatePanel1 runat = server >
< ContentTemplate >
< table align = center >
< tr >
< td >
< asp:标签 ID = Label1 runat = server 文本 = 请选择文件 > < / asp:标签 >
< / td >
< td >
< asp:FileUpload ID = FileUpload1 runat = server / >
< / td >
< td >
< ; / td >
< / tr >
< tr >
< td >
& nbsp; < / td >
< td >
& nbsp; < / td >
< td >
& nbsp ; < / td >
< / tr > ;
< tr >
< td align = center colspan = 3 >
<% - < asp:GridView ID = GridView1 runat = server >
< / asp:GridView > < /跨度> - %GT;
< asp:标签 ID = lbl_count runat = 服务器 > < / asp:标签 >
< / td >
< / tr >
< < span class =code-leadattribute> tr >
< td 对齐 = center colspan = 3 >
& nbsp; < ; / td >
< / tr >
< / table >
< asp:按钮 ID = Button1 runat = server onclick = Button1_Click Text = 上传 < span class =code-attribute> OnClientClick = javascript:showWait(); / >
< asp:UpdateProg ress AssociatedUpdatePanelID = UpdatePanel1 ID = UpdateProgress1 runat = server >
< ProgressTemplate > ;
< asp:Image ID = Image1 runat = server ImageUrl = 〜/ images / ajax -loader.gif / >
< / ProgressTemplate >
< / asp:UpdateProgress >
< / ContentTemplate >
< 触发器 >
< asp:PostBackTrigger ControlID = Button1 / >
<% - < asp:AsyncPostBackTrigger ControlID = Button1 EventName = 点击 /> - %>
< / Triggers >
< / asp:UpdatePanel >
< br / >
< br / >
Homes.aspx.cs
**************************
protected void Button1_Click(object sender,EventArgs e)
{
if(FileUpload1.HasFile)
{
string filename = FileUpload1.FileName;
if(System.IO.File.Exists(Server.MapPath(filename)))
{
System.IO.File.Delete(Server.MapPath(filename)) ;
}
字符串数;
FileUpload1.SaveAs(Server.MapPath(filename));
import_excel(Server.MapPath(filename),out count);
lbl_count.Text = count;
}
}
解决方案
您好我在我的网站上使用了进度条,如下所示它工作正常
Home.aspx:
< pre lang =css>< style>
。 loading
{
font-family : Arial;
font-size : 10pt;
border : 5px solid#67CFF5;
width : 200px;
height : 100px;
display : none;
position : 已修复;
background-color : 白色;
z-index : 999;
}
< / style > ;
< script type =text / javascriptlanguage =javascript> ;;
function ShowProgress(){
setTimeout(function(){
var modal =
('< div />');
modal .addClass(modal);
('body' ).append(modal);
var loading = 跨度>
Hi sir,
Tell me the steps to show update progress while uploading file content to sql server database. I have
40,000 records in excel file, i upload the records into the database, i need to show update progress
while uploading the records into database, its working fine but i cant able to view the update progress.
I attached the code for further details. Kindly give me the solution for this problem.
Homes.aspx:
**************
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<br />
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table align="center">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Please select the file"></asp:Label>
</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td align="center" colspan="3">
<%--<asp:GridView ID="GridView1" runat="server">
</asp:GridView>--%>
<asp:Label ID="lbl_count" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td align="center" colspan="3">
</td>
</tr>
</table>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Upload" OnClientClick="javascript:showWait();" />
<asp:UpdateProgress AssociatedUpdatePanelID="UpdatePanel1" ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/ajax-loader.gif" />
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
<%-- <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />--%>
</Triggers>
</asp:UpdatePanel>
<br />
<br />
Homes.aspx.cs
**************************
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string filename = FileUpload1.FileName;
if (System.IO.File.Exists(Server.MapPath(filename)))
{
System.IO.File.Delete(Server.MapPath(filename));
}
string count;
FileUpload1.SaveAs(Server.MapPath(filename));
import_excel(Server.MapPath(filename), out count);
lbl_count.Text = count;
}
}
解决方案
hi i had used progress bar in my website as follow and it works fine
Home.aspx:
<pre lang="css"><style> .loading { font-family: Arial; font-size: 10pt; border: 5px solid #67CFF5; width: 200px; height: 100px; display: none; position: fixed; background-color: White; z-index: 999; } </style>; <script type="text/javascript" language="javascript">; function ShowProgress() { setTimeout(function () { var modal =
('<div />'); modal.addClass("modal");
('body').append(modal); var loading =
这篇关于如何在将文件内容上传到sql server数据库时显示更新进度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文