asp.net 把单个页面生成静态页面及小知识

     呵呵,本人是新手,有好多东西记不住,望大家多提意见哈

    把页面生成静态页面:

    string url = "http://www.baidu.com/index.php";
            new System.Net.WebClient().DownloadFile(url, Server.MapPath("~/default.html"));

 

      1.asp.net 错误跳转事件
        //错误跳转事件
        protected void Page_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();
            if (ex is HttpRequestValidationException)
            {
                Response.Write("<script language='javascript'>window.location.href='ERROR.htm';</script>");
                Server.ClearError();
            }

        }

      2.文本框后台设置只读属性

         txtstime.Attributes["readonly"] = "true";

      

  网站页面代码总结

   /// <summary>
    /// 绑定时,为删除增加确认对话框
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gvUserList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton del = e.Row.FindControl("lnkbtnDelete") as LinkButton;
            del.Attributes.Add("onclick", "return confirm('确认要删除吗?')");
        }
    }

    /// <summary>
    /// 执行时,设置个人用户详细信息的链接
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gvUserList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "view")
            Response.Redirect("~/admin/UserDetails.aspx?id=" + e.CommandArgument.ToString());
    }

posted @ 2011-07-04 15:29  ElaineHappy  阅读(184)  评论(0编辑  收藏  举报