http://www.cnblogs.com/Gnepner/archive/2011/09/09/2172165.html使用css 样式控制一下应该可以
解决方案 »
- 怎么判断图片的格式呢?
- 用DataContractJsonSerializer解析复杂json遇到的问题,请大家帮忙
- datagrid或datalist中插入checkbox
- 哎,真的不是我吝啬,不知道为啥我现在只有10分了!(还是面向对象的问题!)
- 对话框问题
- asp.net中手写ajax为CallBack函数传参,无法获取服务器返回的值
- 存储过程!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 怎么能让在局域网里的文件夹也web共享呢
- 上传excel后导入数据库的问题!
- 谁有 JavaScript 宝典 “电子版” 电子工业出版(第二版) 如果没有中文的英文也可以,急需,QQ 586255 EMAIL:[email protected] 先谢
- asp.net sql server 数据库 备份
- Div怎么实现页面 "100%"的宽度和高度???
<style>
.MultiFile-applied {
cursor: pointer;
outline: medium none;
vertical-align: middle;
position:absolute;
top:0;
left:0;
width:50px;
height:50px;
z-index:99;
filter:alpha(opacity=0);
-moz-opacity:0;
-khtml-opacity: 0;
opacity: 0;
}
.MultiFile-wrap {
/*background: url("/sysImages/work/upload.gif") no-repeat scroll 0 0 transparent;*/
display: block;
outline: medium none;
position:relative;
cursor:pointer;
}
</style>
...................
<td width="50" height="50" align="center" valign="bottom" onmouseover="this.style.backgroundColor='#D3DAFE';" onmouseout="this.style.backgroundColor='';" >
<a id="uploads_wrap" class="MultiFile-wrap">
<img src="/sysImages/work/upload.gif" width="30" height="30" /><!--这里是图片-->
<iframe src="upload.aspx?no-cache=<%= DateTime.Now.ToString() %>" class="MultiFile-applied" scrolling="no" frameborder="0"></iframe>
</a>
导入
</td>
................................
upload.aspx
<%@ Page Language="C#" EnableEventValidation="false" AutoEventWireup="true"..........................
<!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 id="Head1" runat="server">
<title></title>
<style>
body
{
padding:0px; margin:0px;
}
.MultiFile-applied {
cursor: pointer;
font-size: 40px;
margin-left: -450px;
}
</style>
</head>
<script src="/Scripts/jquery-1.4.1.js"></script>
<body>
<script>
function StarImport(num) {
parent.Import(num);//执行父页的完成事件
}
function showError(error) {
parent.showError(error);//执行父页的错误提示
}
</script>
<form id="form1" runat="server">
<div style="width:50px; height:50px; overflow:hidden;">
<asp:FileUpload ID="FileUpload1" runat="server" CssClass="MultiFile-applied" />
</div>
<div style="display:none"><asp:LinkButton ID="bnt_upload" runat="server" onclick="bnt_upload_Click">LinkButton</asp:LinkButton></div>
</form>
<script>
document.getElementById("FileUpload1").onchange = function () {
if (this.value != "") {
parent.UpdateFileing();//加载父页面的效果显示层,没有可以去掉
__doPostBack('bnt_upload', 'Click');
}
}
</script>
</body>
</html>.cs
protected void bnt_upload_Click(object sender, EventArgs e)
{ if (FileUpload1.PostedFile.FileName == "")
return;
string fileName = Server.HtmlEncode(FileUpload1.FileName);
string extension = System.IO.Path.GetExtension(fileName);
....
文件处理 }
private void showError(string error)
{
this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "im", "showError(\"" + error + "\")", true);
}
1 使用第三方的,上面说的SWFupload uplady 都是很不错的2 自己写的,建议隐藏uploadfile控件,用textbox代替,自定义css+div,自定义textbox和button,点击button的时候用javascript除法fileupload的change事件,通过change事件使用ajax上传