ASPNET:Server Control与Client Script

    protected void Page_Load(object sender, EventArgs e)
    {

        // 客户端代码
        Button1.Attributes["onclick"] = "javascript:return confirm('Are you sure?')";
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Write("You push the button!");
    } 

如果红色部分代码,则程序执行结果为:单击按钮后,选择确定按钮,则出现文字,否则不出现文字.但去掉经色部分代码后无论选择确定还是取消按钮,都会出现文字.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章