温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:淘淘网电子商务网站源码(毕业设计)
当前文件:
TaoTaoBiz/Admin/updown1.aspx.cs,打开代码结构图
TaoTaoBiz/Admin/updown1.aspx.cs,打开代码结构图1using System; 2
using System.Collections; 3
using System.ComponentModel; 4
using System.Data; 5
using System.Drawing; 6
using System.Web; 7
using System.Web.SessionState; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.HtmlControls; 11
12
namespace web.Admin 13
{ 14
/// <summary> 15
/// updown1 的摘要说明。 16
/// </summary> 17
public partial class updown1 : System.Web.UI.Page 18
{ 19
20
protected string FileName = null; 21
protected string FileSaveUrl = null; 22
23
protected void Page_Load(object sender, System.EventArgs e) 24
{ 25
// 在此处放置用户代码以初始化页面 26
} 27
28
Web 窗体设计器生成的代码 47
48
public string ImgUrl 49
{ 50
get{ return FileSaveUrl; } 51
} 52
53
protected void Button1_Click(object sender, System.EventArgs e) 54
{ 55
string fullFileName = upFile.PostedFile.FileName; 56
FileName = fullFileName.Substring( fullFileName.LastIndexOf("\\")+1 ); 57
string FileType = fullFileName.Substring( fullFileName.LastIndexOf(".")+1 ); 58
if( FileType == "bmp" || FileType == "jpg" || FileType == "gif" ) 59
{ 60
FileSaveUrl = "../TopNews/UpDownImg/"+FileName; 61
upFile.PostedFile.SaveAs( Server.MapPath("../TopNews/UpDownImg"+"\\"+FileName) ); 62
Image1.ImageUrl = "../TopNews/UpDownImg/" + FileName; 63
TextBox1.Text = ImgUrl; 64
Response.Write("<script>alert('上传成功!')</script>"); 65
} 66
else 67
{ 68
Response.Write("<script>alert('你上传的文件格式不对!')</script>"); 69
} 70
} 71
72
protected void Button3_Click(object sender, System.EventArgs e) 73
{ 74
RegisterStartupScript("key","<script>window.returnValue=null;window.opener=null;window.close(this);</script>"); 75
} 76
77
protected void Button2_Click(object sender, System.EventArgs e) 78
{ 79
if(TextBox1.Text==null||TextBox1.Text=="") 80
{ 81
Response.Write("<script>alert('请上传图片!')</script>"); 82
} 83
else 84
{ 85
RegisterStartupScript("key","<script>window.returnValue=document.subFrame.TextBox1.value;window.opener=null;window.close(this);</script>"); 86
} 87
} 88
} 89
} 90





}