各位高手,本人用VS2008 C#开发网页。制作网页后,假如用户某输入内容出错,我在后台使用alert弹框,需要他重新输出。这样之后,网页上面的排版就乱了,比如出现字体变化了,12PT的字变大了,还有些地方错位,等等等等,头痛啊,不知道该怎么处理。求教

解决方案 »

  1.   

      //你不会是用这样的方式来后台alert()的吧?
      Response.Write("<script>alert('CSDN-床上等你');</script>");
      

  2.   

       ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('CSDN-床上等你');", true);试试这样的方式
      

  3.   

    直接write会写在html顶部,破坏了代码规范标准,出现显示异常
    用2楼方法可以解决
      

  4.   

    楼上方法可以,一般是可以写一个方法的,每次弹框时调用就可以了public static void WebMessageBox(System.Web.UI.Page page, string values)
            { 
                page.ClientScript.RegisterStartupScript(page.GetType(),"","<script language=javascript>alert('" + values + "')</script>");
            }
    下面是调用示例WebMessageBox(this.Page, "这里写弹出框内容");
      

  5.   

    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('CSDN-床上等你');", true);
    response.write(。。alert)这种方式会改变页面的样式的
      

  6.   

    试试
    Response.Write("<script>alert('CSDN-床上等你');localhost.href=localhost.href</script>");
    Response.End();
      

  7.   

    错了 localhost > location
      

  8.   

    Response.Write 会在页面顶部输出 有时候会破坏页面样式
    用2楼的办法 不过 如果又要执行 alert  之后  又用 loction.href=''   这样的注册JS方法好像不会执行第二句
      

  9.   

    弹出之后重新指定url 
     alert('');location('本页面url')