Response.Write("<script>alert('数据已经存在')</script>");
输出的时候提示不能用说/是换行符
应该怎么写?

解决方案 »

  1.   

    我是写在页面里面的
      包含在<script runat="server">里面的  提示说/是换行符
      不知道怎么写了
      

  2.   

    编译器错误信息: CS1010: 常量中有换行符
    行 109:        {
    行 110:            Response.Write("数据已经存在!");
    行 111:            Response.Write("<script>alert('数据已经存在')</script>");
    行 112:        }
    行 113:        else
      

  3.   

    Response.Write("<script>alert('数据已经存在');</script>");
      

  4.   

    Response.Write(@"<script>alert('数据已经存在')</script>");//试一下下?
      

  5.   

    不行啊
       还是一样的错误!
    <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>