ASP.NET中Postback for FileUpload之前的jQuery函数 [英] jQuery function before the Postback for FileUpload in ASP.NET
问题描述
所以,我有一个.aspx网页如下:
So, I have an .aspx webpage as follows:
..
<form id="frm" runat="server">
<asp:FileUpload runat="server" id="fileupload" onchange="browsed()" />
<asp:Button runat="server" OnClick="Upload_Click" id="uploadbutton" class="uploadbutton" Text="start upload" Enabled="false" />
<div id="nfo" style="display: none">
blabla
</div>
</form>
..
现在,正如您可以猜到的那样,用户选择要上传的文件,点击回复后调用 #uploadbutton
,瞧, Upload_Click
。
然后,我想在上传过程中使用一些jQuery效果显示div #nfo
。为此,我写道:
Now, as you can guess correctly, user chooses file to upload, clicks #uploadbutton
and, voila, Upload_Click
is called after the postback.
Then, I want to show div #nfo
with some jQuery effects during the upload. To do this, I write:
$(function() {
$('.uploadbutton').click(function() {
$('#nfo').slideDown().show("fast");
})
})
一切正常,直到用户开始在IE浏览...
首先,在IE中,用户必须点击 #uploadbutton
两次 - 第一次显示 #nfo
,由于某种原因,第二次启动回发。
其次,在回发后, Upload_Click
的 this.fileupload.HasFile
显示为false。
FF和Chrome虽然效果很好。
and everything works just fine, until the user starts browsing in IE...
First of all, in IE, user has to click #uploadbutton
twice - first time to display #nfo
, second time, for some reason, to initiate postback.
Secondly, after the postback, Upload_Click
's this.fileupload.HasFile
shows false.
FF and Chrome works quite well though.
到目前为止,我可以理解这一点 - 在IE中,jQuery的功能会阻止对重要的事情asp:FileUpload
发生并停止回发。虽然,在第二次点击它确实启动回发,但仍然没有 asp的信息:FileUpload
的 Upload_Click
。
As far, as I can understand this - in IE jQuery's function prevents something important for asp:FileUpload
from happening and stops the postback. Though, on the second click it does initiate the postback, but still with no info for asp:FileUpload
's Upload_Click
.
任何帮助?
更新:
关注@ joelt'd建议。原来,有一些不同的问题,从未认为它可能很重要,所以我没有提供该部分的源代码=(
见本地化< asp:FileUpload> ;.IE问题
推荐答案
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#Button1").click(function() {
$("#progress").show();
});
});
</script>
</head>
<body>
<form runat="server">
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" />
<div id="progress" style="display:none; background-color:Red;">test</div>
</form>
</body>
</html>
这在FF和IE7中对我来说很好,除了在IE中,进度指示器不是真的我想,因为它的呈现方式给你任何东西。我想说我们的代码之间的最大区别是onchange = browsed()函数。在你点击按钮之前,有可能没有被调用?在任何情况下,我都会从这样的精简页面开始,然后开始添加其他元素,直到它中断。
This works fine for me in FF and IE7, except in IE, the progress indicator doesn't really give you anything because of how it's rendering, I suppose. I would say the biggest difference between our code is the "onchange=browsed()" function. It's possible that's not getting called until you click the button? In any case, I would start with a stripped down page like this, and start adding in other elements you have until it breaks.
这篇关于ASP.NET中Postback for FileUpload之前的jQuery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!