中易网

常量中有换行符是怎么回事?

答案:1  悬赏:0  
解决时间 2021-04-28 06:53
  • 提问者网友:浪荡羁士
  • 2021-04-27 15:23
public partial class admin_upload : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button2_Click(object sender, EventArgs e) { Response.Redirect("~/admin/img_manger.aspx"); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { labell.text = ""; string filepath = "~/upload"; if (ImageUpload1.PostedFile != null && ImageUpload1.PostedFile.contentlength != 0) { string nam = ImageUpload1.PostedFile.FileName; string newext = System.IO.Path.GetExtension(nam).ToLower(); Boolean fileok = false; string[] allowext ={ ".jpg", ".gif", ".jpeg" }; for (int a = 0; a < allowext.Length; a++) { if (newext == allowext[i] && (ImageUpload1.PostedFile.ContentLength) <= 204800) fileok = true; } DateTime now1 = DateTime.now; string newnam = now1.ToString("yyyymmddhhmmss") + ImageUpload1.PostedFile.ContentLength.ToString() + newext; if (fileok) { try { ImageUpload1.SaveAs(Server.MapPath(filepath) + "\\" + newnam); string connstring=ConfigurationManager.ConnectionStrings["ASPNETDBConnectionString"].ToString(); using(SqlConnection conn=new SqlConnection(connstring)) { conn.Open(); using(SqlCommand cmd=new SqlCommand("Insert into Picture (UserID,Title,Description,Picture_type,Picture_name)Values (@UserID,@Title,@Description,@Picture_type,@Picture_name)".conn)) { cmd.Parameters.AddWithValue("@UserID",Useridvalue.Text); cmd.Parameters.AddWithValue("@Title",tb_biaoti.Text); cmd.Parameters.AddWithValue("@Description",tb_shuomin.Text); cmd.Parameters.AddWithValue("@Picture_type",ddl_leixin.SelectedValue); cmd.Parameters.AddWithValue("@Picture_name",newnam); cmd.ExecuteNonQuery(); } ClientScript.RegisterStartupScript(this.GetType(),""."alert('相片上传成功!');"); } } catch (Exception Ex) { Lable1.visible = true; Lable1.Text = "Error: " + ex.message; } } else { Label1.visible = true; Label1.text = "你的文件类型不正确或者文件太大,请重新选择..."; } } } } 刚编了一个程序,运行时说常量中有换行符的错误,不知道哪里出错,请好友指教,谢谢
最佳答案
  • 二级知识专家网友:晚安听书人
  • 2021-04-27 15:35
您好,我看到您的问题很久没有人来回答,但是问题过期无人回答会被扣分的并且你的悬赏分也会被没收!所以我给你提几条建议:

一,你可以选择在正确的分类下去提问,这样知道你问题答案的人才会多一些,回答的人也会多些。

二,您可以到与您问题相关专业网站论坛里去看看,那里聚集了许多专业人才,一定可以为你解决问题的。

三,你可以向你的网上好友问友打听,他们会更加真诚热心为你寻找答案的,甚至可以到相关网站直接搜索.

四,网上很多专业论坛以及知识平台,上面也有很多资料,我遇到专业性的问题总是上论坛求解决办法的。

五,将你的问题问的细一些,清楚一些!让人更加容易看懂明白是什么意思!

谢谢采纳我的建议! !!
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息