在系统发邮件,新闻内容发布上要用到freetextbox,用起来是很爽的,但是感觉freetextbox中的定义菜单感觉困难,今天在网上找到了一些资料,和大家分享下
toolbarlayout=”ParagraphMenu,FontFacesMenu,FontSizesMenu,
FontForeColorsMenu,FontForeColorPicker,FontBackColorsMenu,
FontBackColorPicker|Bold,Italic,Underline,Strikethrough,Superscript,
Subscript,RemoveFormat|JustifyLeft,JustifyRight,JustifyCenter,
JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,
Unlink,InsertImage|Cut,Copy,Paste,Delete;Undo,Redo,Print,Save|
SymbolsMenu,StylesMenu,InsertHtmlMenu|InsertRule,InsertDate,
InsertTime|InsertTable,EditTable;InsertTableRowAfter,
InsertTableRowBefore,DeleteTableRow;InsertTableColumnAfter,
InsertTableColumnBefore,DeleteTableColumn|InsertForm,InsertTextBox,
InsertTextArea,InsertRadioButton,InsertCheckBox,InsertDropDownList,
InsertButton|InsertDiv,EditStyle,InsertImageFromGallery,
Preview,SelectAll,WordClean,NetSpell”
Bold 加粗
BulletedList 项目符号
Copy 复制
CreateLink 插入链接
Cut 剪切
Delete 删除
DeleteTableColumn 删除一列(En)
DeleteTableRow 删除一行(En)
IeSpellCheck IE拼写检查(En 需要安装拼写检查软件)
Indent 增加缩进
InsertDate 插入日期
InsertImage 插入图片
InsertRule 插入水平线(En)
InsertTable 插入表格(En)
InsertTableColumnAfter 插入表格列在后面(En)
InsertTableColumnBefore 插入表格列在前面(En)
InsertTableRowAfter 插入表格行在后面(En)
InsertTableRowBefore 插入表格行在前面(En)
InsertTime 插入时间
Italic 斜体
JustifyCenter 居中
JustifyFull 两端对齐
JustifyLeft 左对齐
JustifyRight 右对齐
NetSpell 网络拼写检查(En)
NumberedList 编号
Outdent 减少缩进
Paste 粘贴
Print 打印
Redo 重复
RemoveFormat 删除所有格式
Save 保存(En)
StrikeThrough 删除线
SubScript 下标
SuperScript 上标
Underline 下划线
Undo 撤消
Unlink 删除链接
希望对大家有帮助
js全选和读出对应id和对应值
奉师命实习留校做开发,需要做一个科研项目——影像系统。授命之后开始做需求,经过近十天的努力,大概的需求浮出水面,在以后的日子里面,我会把开 发过程中的一些技术功能模块,我认为有价值贡献出来分享的,虽然很多可能是网上的功能修改而成,但是可以保证都是经过我测试,并且已经消化的知识,如果无 意中侵犯了相关原创作者版权,请与我联系(邮箱:8chf@163.com),我将及时从日志上删除,并从系统功能中除掉。
因为是今天才决定写的,所有前期的有些需求的设计和功能模块就暂时不写出来了,如果后期时间有多余,我将会渐渐的补全。
今天试验课回到宿舍后,考虑到系统在很多地方要实现gridv+checkbox选择(有些要全选)功能,就写了一个,代码如下:
aspx代码:
<asp:GridView ID=”GridView1″ runat=”server” AutoGenerateColumns=”False”
BorderWidth=”0px” DataKeyNames=”id”>
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input id=”Checkbox2″ runat=”server” type=”checkbox” onclick=”CheckAllC(this)”/>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID=”ItemCheckBoxC” runat=”server” />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=”全选”>
<ItemTemplate>
<asp:Label ID=”Label1″ runat=”server” Text='<%# Bind(“id”) %>’ Visible=”false”></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText=”名称”>
<ItemTemplate>
<asp:Label ID=”Label2″ runat=”server” Text='<%# Bind(“username”) %>’></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:Button ID=”Button1″ runat=”server” onclick=”Button1_Click”
Text=”显示选择列id_name” />
cs代码:
</pre> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { bind(); } } private void bind() { DataTable dt = xifenfei.mssql.SqlHelper.ExecuteDataset(xifenfei.mssql.SqlHelper.Connection_test, CommandType.Text, "select id,username from login").Tables[0]; GridView1.DataSource = dt; GridView1.DataBind(); } protected void Button1_Click(object sender, EventArgs e) { string selectid = ""; string selectname = ""; for (int i = 0; i < GridView1.Rows.Count; i++) { CheckBox ch = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("ItemCheckBoxC"); if (ch.Checked) { selectid += GridView1.DataKeys[i].Value.ToString()+";"; Label lbl = (Label)GridView1.Rows[i].FindControl("Label2"); selectname += lbl.Text+";"; } } Response.Write(selectid+"<br />"+selectname); }
js代码
<script type="text/javascript"> function CheckAllC(oCheckbox) { var GridView1 = document.getElementById("<%=GridView1.ClientID %>"); for(i = 1;i < GridView1.rows.length; i++) { GridView1.rows<em>.cells[0].getElementsByTagName("INPUT")[0].checked = oCheckbox.checked; } } </script> </em>
如果有分页的话,要在 GridView1.rows.length的数值上减一
弹出div,锁定界面
js代码:
function showname()//弹出所需模块 { var show=document.getElementById("shown"); show.style.display=""; document.getElementById("shown").style.top="20px"; document.getElementById("shown").style.left="20px"; suoding(); } function suoding()//锁定界面 { var sWidth,sHeight; sWidth=document.documentElement.clientWidth //当前浏览器内部宽度 sHeight=document.documentElement.clientHeight var Sys = {}; var ua = navigator.userAgent.toLowerCase(); if (window.ActiveXObject)//判断ie,如果是7以下版本,采用屏幕的宽度和高度,会导致显示结果有一点滚动条 { Sys.ie = ua.match(/msie ([\d.]+)/)[1] if(Sys.ie<7) { sWidth=screen.width;//显示器宽度,和上面的宽度有一定的出入 sHeight=screen.height; } } var bgObj=document.createElement("div"); bgObj.setAttribute('id','bgDiv'); bgObj.style.position="absolute"; bgObj.style.top="0"; bgObj.style.background="#cccccc"; bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3, opacity=25,finishOpacity=75"; bgObj.style.opacity="0.6"; bgObj.style.left="0"; bgObj.style.width=sWidth + "px"; bgObj.style.height=sHeight + "px"; bgObj.style.zIndex = "50"; document.body.appendChild(bgObj); } function closename()//关闭 { document.getElementById("shown").style.display="none"; var bg=document.getElementById("bgDiv"); if (bg!=null) {//排除有些浏览器不能取到动态div的情况 document.body.removeChild(bg); } }
html代码:
<div style=”width:1000px;height:300px;background-color:blue”> <input type=”button” value=”点击” onclick=”alert(‘adfadsfd’)”></input></div>
<div style=”position:absolute”>
<a href=”#” onclick=”showname()” >显示姓名</a>
<div id=”shown” style=”width:300px;height:200px;background-color:gray; z-index:100; position:absolute;display:none;”><a href=”#” onclick=”closename()” >关闭</a>
</div>
<div style=”background-color:red;width:100px;height:100px;”></div>
</div>
后台管理框架
一直都没有重视ext,以为有jqurey就可以解决所有的js问题了,也许是可以解决,O(∩_∩)O哈哈~,我技术水平还不到哦,不能完全的灵活的使用jquery。
ext虽然比jQuery大多了,但是同样功能也强大多了,我也只是对着网上的手册,稍微的大概的写了一个框架,能够自适应高度,根据不同的用户权限,从xml中读取数据库,显示不同的树形菜单。
不过说到底就是几个iframe组成的,只是比起传统的iframe生硬的组合,而是动态生成的iframe,好看了点,自由点高了点,还考虑了一 些iframe注入的情况。因为代码太多了,我只是把自己写的比较多的一部分拿去来,和大家分享下
Ext.onReady(function() { Ext.BLANK_IMAGE_URL = "ext/resources/images/default/s.gif"; var Tree = Ext.tree; var tree = new Tree.TreePanel({ el: 'west_content', useArrows: true, autoHeight: true, split: true, lines: true, autoScroll: true, animate: true, enableDD: true, border: false, containerScroll: true, loader: new Tree.TreeLoader({ dataUrl: './ext/ext_tree_json.aspx' }) }); // set the root node var root = new Tree.AsyncTreeNode({ text: '影像系统管理员', draggable: false, id: '0' }); tree.setRootNode(root); // render the tree tree.render(); root.expand(); var viewport = new Ext.Viewport({ layout: 'border', items: [{ region: 'west', id: 'west', //el:'panelWest', title: '系统菜单导航', split: true, width: 200, minSize: 200, maxSize: 400, collapsible: true, margins: '160 0 2 2', cmargins: '160 5 2 2', layout: 'fit', layoutConfig: { activeontop: true }, defaults: { bodyStyle: 'margin:0;padding:0;' }, //iconCls:'nav', items: new Ext.TabPanel({ border: false, activeTab: 0, tabPosition: 'bottom', items: [{ contentEl: 'west_content', title: '影像系统后台管理', autoScroll: true, bodyStyle: 'padding:5px;' }] }) }, { region: 'center', el: 'center', deferredRender: false, margins: '160 0 2 0', html: '<iframe id="center-iframe" width="100%" height=100% name="main" frameborder="0" scrolling="auto" style="border:0px none; background-color:#ffffff; " src="admin/articles.aspx"></iframe>', autoScroll: true }, { region: 'south', margins: '0 0 0 2', border: false, html: '<div>版权书写处</div>' } ] }); setTimeout(function() { Ext.get('loading').remove(); Ext.get('loading-mask').fadeOut({ remove: true }); }, 250) });
注:整个框架参考了火舞狂歌-后台管理框架,直接在vs中运行,有时候会出现ie无响应的情况,但是测试在iis和火狐中正常
url重定向
使用Intelligencia.UrlRewriter.dll来实现
在web.config中配置:
(1)在<configSections></configSections>节中加上<section name=”rewriter” requirePermission=”false” type=”Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter” />;
(2)在<httpModules></httpModules>节中加上<add name=”UrlRewriter” type=”Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter”/>;
(3)在<configuration></configuration>节中添 加<rewriter> <rewrite url=”~/(.+).html$” to=”~/ViewNews.aspx?ID=$1″ /> </rewriter> <–重定性规则,按照自己的需求来写,这里对正则表达式基础有点要求–>
测试下,1232.html,是不是出现和id=1232一样的效果。
但是如果你点击该页面的服务器端事件是,url又会变成viewnews.aspx?id=`1232了,这个问题的解决方案网上有两种,一种是重 新form,另一种是重新page,我考虑到保持aspx页面的完整性,采用了重新page的方法来解决,就是一个类文件,在网上下载的叫做 URL.page的,有需要的朋友可以到网上去找下。
动态更好网站背景图片、背景颜色,js调色板
我的思路:管理员可以通过后台添加网站背景图片或者颜色,然后读入数据库中,管理员然后可以从数据库中选择一套模式进行发布出来,显示在前台。把管 理员选择的一套模式相关读入application里面,然后相关页面直接可以通过application里面取得数据库,显示相关页面,从而避免重复读 取数据库,影像网站效率。这其中涉及到两条语句(核心功能实现,我查msdn找到):
body_a.Style.Add(HtmlTextWriterStyle.BackgroundColor, “#123456”);//添加或者改变背景色
body_a.Style.Add(HtmlTextWriterStyle.BackgroundImage, “./img/2.jpg”);//添加或者改变背景图片
我这里添加body的id为body_a,并runat=“server”,这里没用从application里面取数据,直接写入字符串。
调色板:主要是在网上找的,自己稍微加工了下,代码大概公布如下:
js代码:
var ColorHex = new Array('00', '33', '66', '99', 'CC', 'FF') var SpColorHex = new Array('FF0000', '00FF00', '0000FF', 'FFFF00', '00FFFF', 'FF00FF') var current = null function getEvent() { if (document.all) { return window.event; //如果是ie } func = getEvent.caller; while (func != null) { var arg0 = func.arguments[0]; if (arg0) { if ((arg0.constructor == Event || arg0.constructor == MouseEvent) || (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) { return arg0; } } func = func.caller; } return null; } function intocolor() { document.getElementById("colorpanel").style.display = "";//show 调色板 var colorTable = '' for (i = 0; i < 2; i++) { for (j = 0; j < 6; j++) { colorTable = colorTable + '<tr height=12>' colorTable = colorTable + '<td width=11 style="background-color:#000000">' if (i == 0) { colorTable = colorTable + '<td width=11 style="background-color:#' + ColorHex[j] + ColorHex[j] + ColorHex[j] + '">' } else { colorTable = colorTable + '<td width=11 style="background-color:#' + SpColorHex[j] + '">' } colorTable = colorTable + '<td width=11 style="background-color:#000000">' for (k = 0; k < 3; k++) { for (l = 0; l < 6; l++) { colorTable = colorTable + '<td width=11 style="background-color:#' + ColorHex[k + i * 3] + ColorHex[l] + ColorHex[j] + '">' } } } } colorTable = '<table width=253 border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 solid;border-bottom:none;border-collapse: collapse" bordercolor="000000">' + '<tr height=30><td colspan=21 bgcolor=#cccccc>' + '<table cellpadding="0" cellspacing="1" border="0" style="border-collapse: collapse">' + '<tr><td width="3"><td><input type="text" name="DisColor" id="DisColor" size="6" disabled style="border:solid 1px #000000;background-color:#ffff00"></td>' + '<td width="3"><td><input type="text" name="HexColor" id="HexColor" size="7" style="border:inset 1px;font-family:Arial;" value="#000000"></td></tr></table></td></table>' + '<table border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="000000" onmouseover="doOver()" onmouseout="doOut()" onclick="doclick()" style="cursor:hand;">' + colorTable + '</table>'; colorpanel.innerHTML = colorTable } function doOver() { var evt = getEvent(); var element = evt.srcElement || evt.target; var DisColor = document.getElementById("DisColor"); var HexColor = document.getElementById("HexColor"); if ((element.tagName == "TD") && (current != element)) { if (current != null) { current.style.backgroundColor = current._background } element._background = element.style.backgroundColor DisColor.style.backgroundColor = rgbToHex(element.style.backgroundColor) HexColor.value = rgbToHex(element.style.backgroundColor) element.style.backgroundColor = "white" current = element } } /** * firefox 的颜色是以(RGB())出现,进行转换 */ function rgbToHex(aa) { if (aa.indexOf("rgb") != -1) { aa = aa.replace("rgb(", "") aa = aa.replace(")", "") aa = aa.split(",") r = parseInt(aa[0]); g = parseInt(aa[1]); b = parseInt(aa[2]); r = r.toString(16); if (r.length == 1) { r = '0' + r; } g = g.toString(16); if (g.length == 1) { g = '0' + g; } b = b.toString(16); if (b.length == 1) { b = '0' + b; } return ("#" + r + g + b).toUpperCase(); } else { return aa; } } function doOut() { if (current != null) current.style.backgroundColor = current._background; } function doclick() { var evt = getEvent(); var element = evt.srcElement || evt.target; if (element.tagName == "TD") { bg = rgbToHex(element._background); // alert("选取颜色: " + bg); // return bg; document.getElementById("TextBox1").value = bg; document.getElementById("colorpanel").style.display = "none"; //选好颜色后,关闭colorpanel } }
aspx代码:
<table >
<tr>
<td><asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox></td>
<td><input id=”Button1″ type=”button” value=”选取颜色” onclick=”intocolor();” /></td>
</tr>
<tr>
<td><div id=”colorpanel” style=”position: absolute;”></div></td>
<td> </td>
</tr>
</table>
注:外套table是为了,显示的时候稍微美观点
声明:现在公布的代码都是本地测试代码,因为项目还没有正式开始写,外观和功能尚可能还有些bug,这些等待到正式项目中调试;大家如果使用这些代码出现问题,请耐心调试,我保证我都是调试正常并且基本上达到我的需求的代码才会放在日志上的。