本人是个菜鸟,在写上传文件,运行时发现这个问题:
编译器错误消息: CS1519: 类、结构或接口成员声明中的标记“else”无效源错误:
行 30: else
行 31: {
行 32: string strName = this.tb_ProductName.Text;在45行也有一个类似的错误,分别提示在 “if”、“>”和“)”中,类、结构或接口成员声明中的标记无效还有一个错误在第50行: if (type1 == "jpg" || type1 == "bmp" || type1 == "gif" || type1 == "png")
错误提示:“命名空间并不直接包含诸如字段或方法之类的成员”相关代码如下,请各位老大帮帮忙吧,拜托了!! protected void Btn_Submit_Click(object sender, EventArgs e)
{
//45行:
if ((tb_ProductName.Text == "") || (dr_ProductType.Text == "==请选择==") || (tb_kuanshi.Text == "") || (tb_xiulong.Text == "") || (tb_photo.Text == "") || (tb_mianliao.Text == "") || (tb_ling.Text == ""))
Response.Write("<script language=javascript>alert(请添加完整各选项!');location.href='login.aspx';</script>");
}
else
{
string strName = this.tb_ProductName.Text;
string strType = this.dr_ProductType.Text;
string strPingPai = this.tp_PingPai.Text;
string strKuanshi = this.tb_kuanshi .Text;
string strXiuLong = this.tb_xiulong.Text;
string strPhoto = this.tb_photo.Text;
string strMianliao= this.tb_mianliao.Text;
string strStyle = this.tb_style.Text;
string strSeason = this.tb_season.Text;
string tb_ling = this.tb_ling.text;
string tb_Img1 = this.Img1_FileUpload1.FileName;//获取小图的文件的名称如:panjun.doc panjun.gif
string type1 =tb_Img1.Substring(tb_Img1.LastIndexOf(".") + 1).ToLower(); //获取文件的类型
int MaxLength = 1024 * 1024;//最大为1M45行:
if (this.FileUpload1.PostedFile.ContentLength > MaxLength) //限定上传大小为1MB
{
Response.Write("<script>alert('上传文件的大小超过了1MB的最大容量!请压缩后再上传!')</script>");
return;
}
if (type1 == "jpg" || type1 == "bmp" || type1 == "gif" || type1 == "png")
{
string filepath = MapPath("../upload/img/" + name);
if (!File.Exists(filepath))
{
this.FileUpload1.SaveAs(filepath);//这个是主要的完成上传的代码
}
else
{
Response.Write("<script>alert('文件已存在,请重命名后再上传!')</script>");
return;
}
}
else
{
Response.Write("<script>alert('你选择的文件格式不符合要求!')</script>");
return;
}
}
else
{
Response.Write("<script>alert('请选择一个图片文件!')</script>");
return;
} }}
急呀!!在此先谢过了!!!
编译器错误消息: CS1519: 类、结构或接口成员声明中的标记“else”无效源错误:
行 30: else
行 31: {
行 32: string strName = this.tb_ProductName.Text;在45行也有一个类似的错误,分别提示在 “if”、“>”和“)”中,类、结构或接口成员声明中的标记无效还有一个错误在第50行: if (type1 == "jpg" || type1 == "bmp" || type1 == "gif" || type1 == "png")
错误提示:“命名空间并不直接包含诸如字段或方法之类的成员”相关代码如下,请各位老大帮帮忙吧,拜托了!! protected void Btn_Submit_Click(object sender, EventArgs e)
{
//45行:
if ((tb_ProductName.Text == "") || (dr_ProductType.Text == "==请选择==") || (tb_kuanshi.Text == "") || (tb_xiulong.Text == "") || (tb_photo.Text == "") || (tb_mianliao.Text == "") || (tb_ling.Text == ""))
Response.Write("<script language=javascript>alert(请添加完整各选项!');location.href='login.aspx';</script>");
}
else
{
string strName = this.tb_ProductName.Text;
string strType = this.dr_ProductType.Text;
string strPingPai = this.tp_PingPai.Text;
string strKuanshi = this.tb_kuanshi .Text;
string strXiuLong = this.tb_xiulong.Text;
string strPhoto = this.tb_photo.Text;
string strMianliao= this.tb_mianliao.Text;
string strStyle = this.tb_style.Text;
string strSeason = this.tb_season.Text;
string tb_ling = this.tb_ling.text;
string tb_Img1 = this.Img1_FileUpload1.FileName;//获取小图的文件的名称如:panjun.doc panjun.gif
string type1 =tb_Img1.Substring(tb_Img1.LastIndexOf(".") + 1).ToLower(); //获取文件的类型
int MaxLength = 1024 * 1024;//最大为1M45行:
if (this.FileUpload1.PostedFile.ContentLength > MaxLength) //限定上传大小为1MB
{
Response.Write("<script>alert('上传文件的大小超过了1MB的最大容量!请压缩后再上传!')</script>");
return;
}
if (type1 == "jpg" || type1 == "bmp" || type1 == "gif" || type1 == "png")
{
string filepath = MapPath("../upload/img/" + name);
if (!File.Exists(filepath))
{
this.FileUpload1.SaveAs(filepath);//这个是主要的完成上传的代码
}
else
{
Response.Write("<script>alert('文件已存在,请重命名后再上传!')</script>");
return;
}
}
else
{
Response.Write("<script>alert('你选择的文件格式不符合要求!')</script>");
return;
}
}
else
{
Response.Write("<script>alert('请选择一个图片文件!')</script>");
return;
} }}
急呀!!在此先谢过了!!!
解决方案 »
- 一个后台登陆的问题
- 有个sql语句的问题 希望速度解决!
- sqldatasource绑定dropdownlist如何在dropdownlist里加一项all。
- 关于<a href 的 问题
- MzTreeView10雪花树形 问题一个
- 请问一个小问题
- 帮忙写一个sql语句,好像难度蛮大,高手进来挑战一下自我
- 一般控制Web访问流量采用什么方法,有没有相关文档。
- “未能加载类型“Enviroment.kehuleixing.Leixing”会是错在什么地方呢?
- ASP.NET开发的互动.NET留言簿.ver1.5最新版提供源代码下载(开发语言:vb.net)
- radiobuttonlist 问题
- sql查询语句
{
//45行:
if ((tb_ProductName.Text == "") || (dr_ProductType.Text == "==请选择==") || (tb_kuanshi.Text == "") || (tb_xiulong.Text == "") || (tb_photo.Text == "") || (tb_mianliao.Text == "") || (tb_ling.Text == ""))
Response.Write(" <script language=javascript>alert(请添加完整各选项!');location.href='login.aspx'; </script>");
}
else
{
你else怎么能写在这里,不错才怪了
else 却跟在{
这个{是 protected void Btn_Submit_Click(object sender, EventArgs e) 的
Response.Write(" <script language=javascript>alert(请添加完整各选项!');location.href='login.aspx'; </script>");
} 少了个{