protected void Button3_Click(object sender, EventArgs e)
    {
       
        if (TextBox1.Text == "")
        {
          /*在这里如何添加代码出现一个消息提示框呀?提示textbox1.text不能为空*/
         
        }
        else
        {
            TextBox1.ReadOnly = true;
            TextBox2.ReadOnly = false;
            TextBox3.ReadOnly = false;
            Label4.Text = TextBox1.Text;
        }
    }用到了AJAX,请问用js应该如何写呀?初学者刚入门.希望各位写的详细些.谢谢!

解决方案 »

  1.   


    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "s", "alert('textbox1.text不能为空!');", true);
      

  2.   


    或者:
    ClientScript.RegisterClientScriptBlock(this.GetType(), "s","<script>alert('textbox1.text不能为空!')</script>");
      

  3.   

    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "<script>alert('textbox1.text不能为空!</script>');", true);
      

  4.   

    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", " <script>alert('textbox1.text不能为空!'); </script>", true); 
      

  5.   

    除了如一楼二楼说的外
    LZ可以尝试用 RequiredFieldValidator 控件检测为空,省时方便
      

  6.   


     Public FUNCTION Alert( String rtt)
    {
            '顯示提示信息
            System.Web.UI.ScriptManager.RegisterClientScriptBlock(UpdatePanel1, Me.GetType(), "AjaxMsgBox", "alert('" & rtt & "');", True)
       }适用于你的页面包围在updatepanel中
    调用 Alert("不能为空")
      

  7.   

    <script type="text/javascript">
    function yanzhen()
    {
    if(document.getElementByID("ControlID").value=="")
    {
    window.alert('不能为空!');
    return false;
    }
    return true;
    }
    </script>
    Button1.Attributes.Add("onclick","return yanzhen();");