易截截图软件、单文件、免安装、纯绿色、仅160KB

让ASP.Net HTML页面代码 清爽起来

自从用了 ASP.Net MVC后就喜欢上了它 ,因为MVC对服务器控件的依赖大大减少,它生成的HTML页面就比WebForm清爽多了,加载速度有了明显的改善。
但对于页面中内嵌script,还是不能彻底的避免,如:
<script type="text/javascript" language="javascript">
//<!--
function DepositPage() {
// 这是一个第3方的WebControl,由于是服务器控件,受MasterPage影响,它的客户端ID并不是确定的。
this.ctrlRadGrid = "#<%= ctrlRadGrid.ClientID %>";

// 这是一段又臭又长的JSON,从Modal中传递过来
this.accounts = <%= Modal.JSON %>;
// .............................
}
new DepositPage();
// -->
</script>
是否有一种方法可以将这段JS不内嵌在HTML中,使用<script src="">标记从外部文件加载?
答案是肯定的,通过自定义WebControl完全可以实现,有如下WebControl
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
[ParseChildren(false)]
public class ExternalJavascriptControl : WebControl
{
private string SafeFilenamePrefix
{
get
{
return Regex.Replace( this.ClientID
, "(\\\\|\\/|\\:|\\*|\\?|\\\"|\\<|\\>|\\|)"
, "_"
, RegexOptions.ECMAScript | RegexOptions.Compiled
);
}
}
protected override void Render(HtmlTextWriter writer)
{
if (!Visible)
return;
try
{
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
base.Render(htw);
// get the rendered content
string rendered = sw.ToString();
// remove the script tag if exist
rendered = Regex.Replace(rendered
, @"(<[\s\/]*script\b[^>]*>)"
, string.Empty
, RegexOptions.ECMAScript | RegexOptions.Compiled | RegexOptions.IgnoreCase
);
// get the file pa


相关文档:

asp.net数据绑定之Eval和Bind 和等区别

Eval是asp.net1.1中常
用的绑定语法,它是“单向”的,即绑定时把数据源上相应的值赋到该控件上,Eval的任务就完成了
而Bind所谓的“双向”就是:在绑定时,把
数据源上相应的值赋到该控件上,并且,在提交时,自动提取用户在该控件上输入的值。
Code
<
EditItemTemplate
>
 
&nb ......

html中加载flash后的路径问题

在页面A中加载了一个flash文件a.swf后,a.swf的路径就会变成A所在的路径。如果在a.swf中要加载b.swf时,这时候的路径就要进行相应的处理。
本来按照a.swf和b.swf在磁盘中的存放路径,a中加载b是很简单的,但是现在a.swf已经变成页面A所在的路径了,如果还是安装原来的路径去加载b.swf就加载不了了。因此可以在as代码加载b ......

html读书笔记

     1 HTML是超文本标记语言,是浏览器的"母语",我们所看到的网页就是浏览器对HTML进行解释的结果。而XHTML是可扩展超文本标记语言,是一种新的更加结构良好的HTML语言。
    2、HTML主要是各种各样的元素,学习HTML就是学习使用这些元素。
    3、元素一 ......

在asp.net中怎样跳转框架

我有一个login.aspx的页面,假如登录成功后就会自动跳转到index.html的框架. 
index.html有三个页面,top.aspx,left.aspx,main.aspx,然后left.aspx里面显示用户信息 
假如在left.aspx里没有Session的话,会返回login.aspx页面,而不显示index.html页面里的任何一页. 
我现在的情况是没有Session的时候还是在i ......

ASP.NET中解决传递中文参数

1.设置web.config文件.
<system.web>
......
<globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312" />
......
</system.web>
 
或者:
aspx文件中:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"&g ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号