找回密码
 立即注册

微信扫码登录

QQ登录

只需一步,快速开始

搜索
查看: 2601|回复: 1

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

[复制链接]

23

主题

17

回帖

546

积分

三星会员

积分
546
性别
保密
发表于 2009-12-7 09:02:47 | 显示全部楼层 |阅读模式
呵呵,仅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[0] = i;
            dr[1] = "Val" + i.ToString();
            dr[2] = "Val" + i.ToString();
            dr[3] = "Val" + i.ToString();
            dt.Rows.Add(dr);
        }
        DataSet ds = new DataSet();
        ds.Tables.Add(dt);
        return ds;
    }
}
QQ交流:357700106 http://www.embedcn.com
回复

使用道具 举报

23

主题

17

回帖

546

积分

三星会员

积分
546
性别
保密
 楼主| 发表于 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应用程序。

另外,缓存功能也有其自身的不足。例如,显示的内容可能不是最新、最准确的,为此,必须设置合适的缓存策略。又如,缓存增加了系统的复杂性并使其难于测试和调试,因此建议在没有缓存的情况下开发和测试应用程序,然后在性能优化阶段启用缓存选项。
QQ交流:357700106 http://www.embedcn.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|发图教程|( 皖ICP备19025135号-3|皖公安备案号34082302000108 )|网站地图

GMT+8, 2025-5-4 17:26

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表