请教小问题高手问题 Response.Write("<script>alert('数据已经存在')</script>");输出的时候提示不能用说/是换行符应该怎么写? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我是写在页面里面的 包含在<script runat="server">里面的 提示说/是换行符 不知道怎么写了 编译器错误信息: CS1010: 常量中有换行符行 109: {行 110: Response.Write("数据已经存在!");行 111: Response.Write("<script>alert('数据已经存在')</script>");行 112: }行 113: else Response.Write("<script>alert('数据已经存在');</script>"); Response.Write(@"<script>alert('数据已经存在')</script>");//试一下下? 不行啊 还是一样的错误!<script runat="server"> private void Page_Load(Object sender, EventArgs e){if(!Page.IsPostBack){ImgPreview.Visible=false;}}void GetThumbnailImage(int width,int height,string strInfo,int left,int right){ string file = "image/" + uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\\') + 1); string newfile = "image/" + uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\\') + 1) + ".jpg";string strAdd=strInfo;System.Drawing.Image oldimage = System.Drawing.Image.FromFile(Server.MapPath(file));System.Drawing.Image thumbnailImage =oldimage.GetThumbnailImage(width, height,new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);Response.Clear();Bitmap output=new Bitmap(thumbnailImage);Graphics g=Graphics.FromImage(output);g.DrawString(strAdd,new Font("Courier New", 14),new SolidBrush(Color.Red),left,right);output.Save(Server.MapPath(newfile),System.Drawing.Imaging.ImageFormat.Jpeg);Response.ContentType = "image/gif";ImgPreview.Visible=true;ImgPreview.ImageUrl=newfile;Label1.Text = "生成新图片显示:"; Oldimage.Text = file;Newimage.Text = newfile;}bool ThumbnailCallback(){return true;}void Button_Click(object sender, EventArgs e){int width,height,left,right;string strAddInfo=txtAddInfo.Text;width=Int32.Parse(txtWidth.Text);height=Int32.Parse(txtHeight.Text);left=Int32.Parse(txtLeft.Text);right=Int32.Parse(txtRight.Text);if(!(uploadFile.PostedFile.ContentLength>0)){lblErrInfo.Text="没有选择文件!";}else{string path = Server.MapPath("./image/"+uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\\')+1));if(File.Exists(path)){lblErrInfo.Text="已经有同名文件!";}else{uploadFile.PostedFile.SaveAs(path); GetThumbnailImage(width,height,strAddInfo,left,right);starimage.Text = "";lblErrInfo.Text = "";} } }protected void starn_Click(object sender, EventArgs e){ if (TextBox1.Text.Trim() == "") { starname.Text = "信息简称不能为空!"; startext.Text = ""; starimage.Text = ""; } else if (TextBox3.Text.Trim() == "") { startext.Text = "请填写下面的详细信息!"; starname.Text = ""; starimage.Text = ""; } else if (Oldimage.Text.Trim() == "" || Newimage.Text.Trim() == "") { starimage.Text = "请先上传图片!"; startext.Text = ""; starname.Text = ""; } else { starname.Text = ""; startext.Text = ""; starimage.Text = ""; string star1=DropDownList1.Text.ToString(); string star2 = TextBox1.Text; string star3 = TextBox3.Text; string Oldimages=Oldimage.Text; string Newimages=Newimage.Text; string starconn = "user id=sa;password=123;initial catalog=aspx;server=KEYJOB;Connect TimeOut=60"; SqlConnection conn = new SqlConnection(starconn); conn.Open(); SqlCommand star = new SqlCommand("select * from admintext where starname='" + star2 + "'", conn); SqlDataReader stars = star.ExecuteReader(); if (stars.Read()) { Response.Write("数据已经存在!"); } else { stars.Close(); SqlCommand starrs = new SqlCommand("insert into admintext (titleid,starname,inttime,startext,Oldimage,Newimage) values('" + star1 + "','" + star2 + "','" + System.DateTime.Now + "','" + star3 + "','" + Oldimages + "','" + Newimages + "')", conn); SqlDataReader rs = starrs.ExecuteReader(); if (rs.Read()) { Response.Write("数据添加成功!"); } } }}protected void Button2_Click(object sender, EventArgs e){ TextBox1.Text = ""; starimage.Text = ""; starname.Text = ""; startext.Text = ""; TextBox3.Text = ""; TextBox1.Text = ""; Oldimage.Text = ""; Newimage.Text = ""; ImgPreview.ImageUrl = ""; ImgPreview.Visible = false; Label1.Text = "";}</script> C#不同窗体传值问题,在线等,求答案 求助一个后台SQL的C#学生管理系统 datagridview添加合计行 【web问题】服务器向客服端发送confirm 用C#。能写一个通用的SQL查询,插入,更新的类吗? "您请求的报表需要更多信息"问题 为什么Session失去的时候有时候会出现错误 我想做一个分布式应用程序但命名空间System.Runtime.Remoting.Channels.Tcp中的Tcp显示不了,怎么回事啊? 谁能帮我解决这个问题? 那里有vs.net的中文版的下载呀!告诉准确,给分 2007年8月C#版务专用帖 怎么获取本地默认打印机的名字?
包含在<script runat="server">里面的 提示说/是换行符
不知道怎么写了
行 109: {
行 110: Response.Write("数据已经存在!");
行 111: Response.Write("<script>alert('数据已经存在')</script>");
行 112: }
行 113: else
还是一样的错误!
<script runat="server">
private void Page_Load(Object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
ImgPreview.Visible=false;
}
}
void GetThumbnailImage(int width,int height,string strInfo,int left,int right)
{
string file = "image/" + uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\\') + 1);
string newfile = "image/" + uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\\') + 1) + ".jpg";
string strAdd=strInfo;
System.Drawing.Image oldimage = System.Drawing.Image.FromFile(Server.MapPath(file));
System.Drawing.Image thumbnailImage =
oldimage.GetThumbnailImage(width, height,new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
Response.Clear();
Bitmap output=new Bitmap(thumbnailImage);
Graphics g=Graphics.FromImage(output);
g.DrawString(strAdd,new Font("Courier New", 14),new SolidBrush(Color.Red),left,right);
output.Save(Server.MapPath(newfile),System.Drawing.Imaging.ImageFormat.Jpeg);
Response.ContentType = "image/gif";
ImgPreview.Visible=true;
ImgPreview.ImageUrl=newfile;
Label1.Text = "生成新图片显示:";
Oldimage.Text = file;
Newimage.Text = newfile;
}
bool ThumbnailCallback()
{
return true;
}void Button_Click(object sender, EventArgs e)
{
int width,height,left,right;
string strAddInfo=txtAddInfo.Text;
width=Int32.Parse(txtWidth.Text);
height=Int32.Parse(txtHeight.Text);
left=Int32.Parse(txtLeft.Text);
right=Int32.Parse(txtRight.Text);
if(!(uploadFile.PostedFile.ContentLength>0))
{
lblErrInfo.Text="没有选择文件!";
}
else
{string path = Server.MapPath("./image/"+uploadFile.PostedFile.FileName.Substring(uploadFile.PostedFile.FileName.LastIndexOf('\\')+1));
if(File.Exists(path))
{
lblErrInfo.Text="已经有同名文件!";
}
else
{
uploadFile.PostedFile.SaveAs(path);
GetThumbnailImage(width,height,strAddInfo,left,right);
starimage.Text = "";
lblErrInfo.Text = "";
}
}
}
protected void starn_Click(object sender, EventArgs e)
{ if (TextBox1.Text.Trim() == "")
{
starname.Text = "信息简称不能为空!";
startext.Text = "";
starimage.Text = "";
}
else if (TextBox3.Text.Trim() == "")
{
startext.Text = "请填写下面的详细信息!";
starname.Text = "";
starimage.Text = "";
}
else if (Oldimage.Text.Trim() == "" || Newimage.Text.Trim() == "")
{
starimage.Text = "请先上传图片!";
startext.Text = "";
starname.Text = "";
}
else
{
starname.Text = "";
startext.Text = "";
starimage.Text = "";
string star1=DropDownList1.Text.ToString();
string star2 = TextBox1.Text;
string star3 = TextBox3.Text;
string Oldimages=Oldimage.Text;
string Newimages=Newimage.Text;
string starconn = "user id=sa;password=123;initial catalog=aspx;server=KEYJOB;Connect TimeOut=60";
SqlConnection conn = new SqlConnection(starconn);
conn.Open();
SqlCommand star = new SqlCommand("select * from admintext where starname='" + star2 + "'", conn);
SqlDataReader stars = star.ExecuteReader();
if (stars.Read())
{
Response.Write("数据已经存在!");
}
else
{
stars.Close();
SqlCommand starrs = new SqlCommand("insert into admintext (titleid,starname,inttime,startext,Oldimage,Newimage) values('" + star1 + "','" + star2 + "','" + System.DateTime.Now + "','" + star3 + "','" + Oldimages + "','" + Newimages + "')", conn);
SqlDataReader rs = starrs.ExecuteReader();
if (rs.Read())
{
Response.Write("数据添加成功!");
}
}
}}
protected void Button2_Click(object sender, EventArgs e)
{
TextBox1.Text = "";
starimage.Text = "";
starname.Text = "";
startext.Text = "";
TextBox3.Text = "";
TextBox1.Text = "";
Oldimage.Text = "";
Newimage.Text = "";
ImgPreview.ImageUrl = "";
ImgPreview.Visible = false;
Label1.Text = "";
}
</script>