wawa 发表于 2009-12-7 09:02:47

ASP.NET技巧:使Div内内容可编辑

呵呵,仅IE有效:)
前台代码:
<%@ Page Language="C#" AutoEventWireup="true"CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="width:600px;height:400px;" id="div1">
      <asp:GridView ID="GridView1" runat="server" Height="300px" Width="200px">
      </asp:GridView>
         </div>
    <script language="javascript" type="text/javascript">
       document.getElementById("div1").contentEditable = true;
       document.execCommand('2D-Position', true, true);
    </script>
    </form>
</body>
</html>后台代码:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack)
      {
            GridView1.Style.Add("position", "absolute");
            GridView1.DataSource = GetDataSet();
            GridView1.DataMember = "testtable";
            GridView1.DataBind();
      }
    }
    private DataSet GetDataSet()
    {
      DataTable dt = new DataTable("testtable");
      dt.Columns.Add("Col1", typeof(int));
      dt.Columns.Add("Col2", typeof(string));
      dt.Columns.Add("Col3", typeof(string));
      dt.Columns.Add("Col4", typeof(string));
      DataRow dr;
      for (int i = 0; i < 10; i++)
      {
            dr = dt.NewRow();
            dr = i;
            dr = "Val" + i.ToString();
            dr = "Val" + i.ToString();
            dr = "Val" + i.ToString();
            dt.Rows.Add(dr);
      }
      DataSet ds = new DataSet();
      ds.Tables.Add(dt);
      return ds;
    }
}

wawa 发表于 2009-12-7 09:12:38

ASP.NET技术简介:ASP.NET 2.0的缓存功能具有以下优点:

◆支持更为广泛和灵活的可开发特征

ASP.NET 2.0包含一些新增的缓存控件和API。例如,自定义缓存依赖、Substitution控件、页面输出缓存API等,这些特征能够明显改善开发人员对于缓存功能的控制。

◆增强的可管理性

使用ASP.NET 2.0提供的配置和管理功能,可以更加轻松地管理缓存功能。

◆提供更高的性能和可伸缩性

ASP.NET 2.0提供了一些新的功能,例如,SQL数据缓存依赖等,这些功能将帮助开发人员创建高性能、伸缩性强的Web应用程序。

另外,缓存功能也有其自身的不足。例如,显示的内容可能不是最新、最准确的,为此,必须设置合适的缓存策略。又如,缓存增加了系统的复杂性并使其难于测试和调试,因此建议在没有缓存的情况下开发和测试应用程序,然后在性能优化阶段启用缓存选项。
页: [1]
查看完整版本: ASP.NET技巧:使Div内内容可编辑