请教小问题高手问题

zhangjingcheng 2007-09-01 11:00:39
Response.Write("<script>alert('数据已经存在')</script>");
输出的时候提示不能用说/是换行符
应该怎么写?
...全文
119 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangjingcheng 2007-09-03
  • 打赏
  • 举报
回复
怎么就没人呢?
bbdog 2007-09-01
  • 打赏
  • 举报
回复
Response.Write(@"<script>alert('数据已经存在')</script>");//试一下下?
zhangjingcheng 2007-09-01
  • 打赏
  • 举报
回复
一个样子
wjg06 2007-09-01
  • 打赏
  • 举报
回复
Response.Write("<script>alert('数据已经存在');</script>");
zhangjingcheng 2007-09-01
  • 打赏
  • 举报
回复
编译器错误信息: CS1010: 常量中有换行符
行 109: {
行 110: Response.Write("数据已经存在!");
行 111: Response.Write("<script>alert('数据已经存在')</script>");
行 112: }
行 113: else
zhangjingcheng 2007-09-01
  • 打赏
  • 举报
回复
我是写在页面里面的
包含在<script runat="server">里面的 提示说/是换行符
不知道怎么写了
sky_97 2007-09-01
  • 打赏
  • 举报
回复
应该没有问题啊
zhangjingcheng 2007-09-01
  • 打赏
  • 举报
回复
不行啊
还是一样的错误!
<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>

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧