温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:淘淘网电子商务网站源码(毕业设计)
当前文件:
TaoTaoBiz/Admin/updown.aspx.cs,打开代码结构图
TaoTaoBiz/Admin/updown.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
/// updown 的摘要说明。 16
/// </summary> 17
public partial class updown : 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
// Button2.Attributes.Add("onclick", "return btnOpen_Click();"); 27
} 28
29
Web 窗体设计器生成的代码 48
49
public string ImgUrl 50
{ 51
get{ return FileSaveUrl; } 52
} 53
54
protected void Button1_Click(object sender, System.EventArgs e) 55
{ 56
string fullFileName = upFile.PostedFile.FileName; 57
FileName = fullFileName.Substring( fullFileName.LastIndexOf("\\")+1 ); 58
string FileType = fullFileName.Substring( fullFileName.LastIndexOf(".")+1 ); 59
if( FileType == "bmp" || FileType == "jpg" || FileType == "gif" ) 60
{ 61
FileSaveUrl = "UpDownImg/"+FileName; 62
upFile.PostedFile.SaveAs( Server.MapPath("../TopNews/UpDownImg"+"\\"+FileName) ); 63
Image1.ImageUrl = "../TopNews/UpDownImg/" + FileName; 64
TextBox1.Text = ImgUrl; 65
Response.Write("<script>alert('上传成功!')</script>"); 66
} 67
else 68
{ 69
Response.Write("<script>alert('你上传的文件格式不对!')</script>"); 70
} 71
} 72
73
protected void Button2_Click(object sender, System.EventArgs e) 74
{ 75
if(TextBox1.Text==null||TextBox1.Text=="") 76
{ 77
Response.Write("<script>alert('请上传图片!')</script>"); 78
} 79
else 80
{ 81
RegisterStartupScript("key","<script>window.returnValue=document.subFrame.TextBox1.value;window.opener=null;window.close(this);</script>"); 82
} 83
} 84
85
protected void Button3_Click(object sender, System.EventArgs e) 86
{ 87
RegisterStartupScript("key","<script>window.returnValue=null;window.opener=null;window.close(this);</script>"); 88
} 89
} 90
} 91





}