星☆空 | 对生活要知足,学习要不知足,为人处事要知不足. 卍 ♂ | ♀ 卐 - 科技以人为本.

QQ:908202921, Msn:btbtd@live.com gI.2288.oRg:88 绿色学院 - GrEeN InsTiTutE, www.btbtd.org

原创 c# .net 编写 HTML 编辑器的核心技巧 by shawl.qiu收藏

c# .net 编写 HTML 编辑器的核心技巧 by shawl.qiu


说明:
之前我写过一个 纯 js 的 HTML 编辑器 sqEditor.
这里: http://blog.csdn.net/btbtd/archive/2007/01/16/1484070.aspx
那时是在使用 asp/vbs, asp/js 的脚本语言.

现在俺需要自己的 .net 版 HTML 编辑器,
其实不难写, 不外乎与 iframe 的数据读取, 然后再加个 submit 的 EventHandler
至于其他的操作, 跟我上次写的 纯 JS HTML 编辑器 没多大区别.

广告时间, sqEditor for .net 不日推出.

目录:
1. x.aspx
2. ac/sqEditor.ascx

shawl.qiu
2007-02-28
http://blog.csdn.net/btbtd

内容:
1. x.aspx

  1. <%@ Page Language="C#AutoEventWireup="True" %>
  2. <%@ Reference Control="ac/sqEditor.ascx" %>
  3. <script runat="server">
  4.  void Page_Load(Object s, EventArgs e)
  5.  {
  6.   Control sqEditor = LoadControl("ac/sqEditor.ascx");
  7.   sqEditorPlaceHolder.Controls.Add(sqEditor);
  8.  } // end Page_Load
  9. </script>
  10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  11. <html xmlns="http://www.w3.org/1999/xhtml">
  12. <head>
  13. <meta http-equiv="Content-Typecontent="text/html; charset=utf-8" />
  14. <title>shawl.qiu template</title>
  15. </head>
  16. <body>
  17.  <form runat="server">
  18.   <asp:PlaceHolder id=sqEditorPlaceHolder runat=server 
  19.    />
  20.  </form>
  21. </body>
  22. </html>
  23.  
2. ac/sqEditor.ascx
  1. <%@ Control Language="C#AutoEventWireup="TrueclassName="sqEditor" %>
  2. <script runat="server">

  3.  void Page_Load(Object s, EventArgs e)
  4.  {
  5.   edSubmit.Attributes["onclick"] = 
  6.    "return fSetInnerHtml('"+ifm.ClientID+"','"+t.ClientID+"')";
  7.   
  8.   edSubmit.Click += new EventHandler(submit);
  9.  } // end Page_Load
  10.  
  11.  private void submit(Object s, EventArgs e)
  12.  {
  13.   Response.Write("<li/>~~~~~~~~"+t.Text);
  14.  }
  15. </script>

  16. <style type="text/css">
  17. /* <![CDATA[ */
  18.  .dspHd {display:none!important;}
  19. /* ]]> */
  20. </style>

  21. <script type="text/javascript">
  22. //<![CDATA[
  23.  onload=function()
  24.  {
  25.   fIntiIframe("<% Response.Write(ifm.ClientID); %>", "temp");
  26.  }
  27.  
  28.  function fIntiIframe(sId, sTempContentId)
  29.  {
  30.   try{
  31.    var ifmWin=document.getElementById(sId).contentWindow;
  32.    var ifmDcu=ifmWin.document;
  33.  
  34.    var sCt=document.getElementById(sTempContentId)
  35.    if(sCt!=nullsCt=sCt.innerHTML;
  36.    
  37.    ifmDcu.designMode="on";
  38.    ifmDcu.contentEditable=true;
  39.    ifmDcu.open();
  40.    if(!sCt) ifmDcu.write('--------&nbsp;'); else ifmDcu.write(sCt);
  41.    ifmDcu.close()
  42.    } catch(e){}
  43.  }
  44.   
  45.  function fSetInnerHtml(sId, sDivId)
  46.  { 
  47.    var ifmWin=document.getElementById(sId).contentWindow;
  48.    var ifmDcu=ifmWin.document;
  49.    var html = ifmDcu.body.innerHTML;
  50.    
  51.    var ifm = document.getElementById(sDivId);
  52.    ifm.value = html;
  53.   try{
  54.    } catch(e){}
  55.    return true;
  56.  }
  57. //]]>
  58. </script>
  59. <iFrame id=ifm runat=server></iFrame>
  60. <br/>
  61. <asp:Button id=edSubmit runat=server
  62.  Text = "Submit"
  63.  />
  64. <asp:TextBox id=t runat=server
  65.  CssClass="dspHd"
  66. /> 

 

发表于 @ 2007年02月28日 18:18:00|评论(loading...)

新一篇: sqEditor HTML 编辑器 for .net v1.0 By shawl.qiu | 旧一篇: shawl.qiu c# .net FileManager class v1.0(文件管理器)

用户操作
[即时聊天] [发私信] [加为好友]
邱少伟
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
邱少伟的公告
www.btbtd.org
gi.2288.org
文章分类
收藏
#1. Algorithm
Bit Twiddling Hacks - By Sean Eron Anderson
Paj's Home
XySSL
高度な JavaScript 技集
0. ASP
aspfaq.com
codeproject.com
motobit.com
0. ASP.NET(C#)
ASP .NET FAQ
C# Frequently Asked Questions
C# General FAQ
C# MVP Bloggers
0. CSS
Comparison of layout engines (CSS)
0. Javascript
Comparison of layout engines (DOM)
Comparison of layout engines (ECMAScript)
crockford.com
faqts.com/javascript
Pat's Place: A technology demonstrator project.
0. SQL
Comparison of different SQL implementations
Comparison of SQL syntax
What are reserved Access, ODBC and SQL Server keywords?
What are the main differences between Access and SQL Server?
0. Tool Kits
ECMA Standards
faqts.com
Mozilla docs
RFC's
W3C TR
1. Search Engines
Alexa Web Search
All the web
AltaVista Search
AOL Web Search
Baidu
CrazySearch!
CSDN Blog Search
Excite
FeedsS's Blog
Google
Kingsoft
Lycos Search
Lyric Search
Mpeg Search
MSN Search
Search.com
SoGua
Soudu
xx-hacker
Yahoo [cn]
Yahoo [en]
Yisou
2. English Forum
#旺旺英语论坛
#英语写作论坛
Learners english club
3. Linux Forum
#三峡大学 LINUX联盟(RSS)
#中国 Linux 公社(RSS)
#黄嘴企鹅论坛(RSS)
Fedora 1.0 问题(RSS)
LINUX 1000 Q(RSS)
Linux 伊甸园(RSS)
4. PHP Forum
#中文PHP俱乐部(RSS)
#超越 PHP(RSS)
5. Other Site
#中国网络研究与搜索论坛
#在线翻译(RSS)
#常用书籍打包
#电子图书下载(RSS)
#科迈网(RSS)
#蓝色理想(RSS)
#西安信息资源网
CSDN.NET(RSS)
Google Hacker Database
Web Design Group
Webmaster world
6. Enjoy Site
#新华网论坛(RSS)
#极点视觉绘画站(RSS)
#涂鸦王国(RSS)
#牧文财经(RSS)
#猫扑大杂烩(RSS)
7. Resource
Active Perl
Apache
j2sdk-1_4_2-windows-i586
mm.mysql-2.0.4-bin.jar
mod_jk_1.2.5_2.0.47.dll
mod_rewrite
MySql
PHP
phpMailer
Source Forge Xoops
Tomcat
Web Server Resource
Win2k3
Zend
8. My Blog
#搜索引擎优化 Seo-GI
#绿色学院 - Green Institute
Blogcn(RSS)
GI Technology
GI-BB Developer Team
Green Institute
MSN Blog
Wallop Flash
Wallop HTML (RSS)
卐-_卍 信仰,理想,追求,博爱,自强,厚德.(RSS)
9. Music & Album
GaeAhit
USTC
VeryCD-MTV
A. Manual
Apache Manual
CSS Level 2 Manual
HTML 4.01 Manual
Javascript Manual
MySql Manual (cn) 2
MySql Manual (en) 1
PEAR Manual
PHP Manual
PHP-GTK Manual
Regular Expression Library
Smarty Manual
W3C Technical Reports and Publications
XHTML 1.0 Manual
XML 1.0 Manual
B. Google Cheat
Blog.com
ChinaUnix
cnblogs
donews
Google Groups
Teeta
Tom blog
Yahoo Groups
Yculblog
C. Friend's Blog
#我爱生命中存在的那一切(RSS)
#老贼在干嘛?(RSS)
#鸣乐谷
Color_Se SeSe 颜色(RSS)
Drink Drank Drunk
PLANTUNT的珍贵资源
D. SEO
Keywords 1 (Google)
Keywords 2 (Baidu)
Keywords 3 (Yisou)
Marketleap.com
Pagerank 1
Pagerank 2
Pagerank 3
Trafficzap.com
Uptimebot.com
Webconfs
E. Technology
http://bt.it.to/
http://bt.qq.to/
http://bt.zz.to/
http://du.u.to/
http://gi.dd.to/
http://gi.if.to/
http://gi.kk.to/
http://gi.pc.to
http://gi.xx.to/
http://mail.it.to/
http://nba.it.to
http://se.u.to/
F. Literature
#逐浪文学
KK 书库
G. Math/Geometry
台湾一个不错的数学站
H. Works
宝莱迪
I. SEO Link
paolid
shawl.qiu CSharp DotNet 个人资料管理系统
shawl.qiu CSharp DotNet 个人资料管理系统
shawl.qiu CSharp DotNet 个人资料管理系统
依梦卫浴-依梦洁具(北京)厂家直销店
卫浴生活坊
满意洁具馆
热弯玻璃
热熔玻璃
热熔玻璃
玻璃
玻璃制品
艺术玻璃
存档
软件项目交易
Csdn Blog version 3.1a
Copyright © 邱少伟