All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
基础知识之认识和使用,RSS+asp.net_.net资料_编程技术
php如何判断来访网页地址_[PHP教程]
Visual C++ 6.0教程:c++数据类型之结构
asp.net2.0对Repeater数据控件进行绑定
C#教程:测试COM+应用程序
SQL,Server,安装,(SQL,Server,2008,R2)_mssql学习_编程技术
在ASP.NET中自动给URL加上超链接_[Asp.Net教程]
解决错误:sql_variant,is,incompatible,with,xml,(ASP.NET_[Asp.Net教程]
ASP.NET实现自适应图片大小的弹出窗口(窗口可任意编辑)_[Asp.Net教程]
JS页内查找关键词的高亮显示_JavaScript技术_编程技术
Reading number is top 10 pictures
中国文革时期的色情图片2
职场回春术
美女浴室写真1
Ashlynn Brooke show proud chest measurement2
A cat have life principles
狗狗与主人神同步1
西游四格漫画(六)
运动的范冰冰2
29 the belle stars after bath figure5
The wise woman of chest2
Download software ranking
matrix3
仙剑奇侠传98硬盘WINXP版
美女写真1
天龙八部最新服务端
卡丁车单机版
The hero
在线棋牌游戏3.05版
linux高级编程
Unix video tutorial10
Boxer's Top ten classic battle9
归海一刀 published in(发表于) 2014/3/16 2:55:41 Edit(编辑)
结合MS AJAX将js文件编译到动态链接库_[AJAX教程]

结合MS AJAX将js文件编译到动态链接库_[AJAX教程]

结合MS AJAX将js文件编译到动态链接库_[AJAX教程]























为了使javascript代码不被窃取,我们可以将js文件编译成动态链接库(dll)文件。下面为了演示这一功能,创建了一个控件。


程序代码:http://www.cnblogs.com/Files/hblynn/SampleControlsCS.rar




一、创建一个类库项目,命名为UpdateAnimate。




二、向项目中添加引用System.Web, System.Drawing, System.Web.Extensions




三、向项目中添加一个Jscript的文件UpdatePanelAnimation.js




四、向文件中添加如下代码:





BorderAnimation = function(color)
{
this._color = color;
}




BorderAnimation.prototype =
{
animate: function(panelElement)
{
var s = panelElement.style;
s.borderWidth = '2px';
s.borderColor = this._color;
s.borderStyle = 'solid';




window.setTimeout(
function()
{
{
s.borderWidth = 0;
}
},
500);
}
}





这段代码中,包含一段临时改变UpdatePanel控件样式的方法







五、解决方案资源管理器中,右键查看UpdatePanelAnimation.js的属性,把高级中的“生成操作”属性设置成“嵌入的资源”。




六、向项目中添加一个类CustomControl




七、替换类中的代码:




using System;
using System.Drawing;
using System.Web.UI;
using System.Web;
using System.Globalization;




namespace UpdateAnimate
{
public class UpdatePanelAnimationWithClientResource : Control
{
private string _updatePanelID;
private Color _borderColor;
private Boolean _animate;
public Color BorderColor
{
get
{
return _borderColor;
}
set
{
_borderColor = value;
}
}




public string UpdatePanelID
{
get
{
return _updatePanelID;
}
set
{
_updatePanelID = value;
}
}




public Boolean Animate
{
get
{
return _animate;
}
set
{
_animate = value;
}
}
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
if (Animate)
{




UpdatePanel updatePanel = (UpdatePanel)FindControl(UpdatePanelID);




string script = String.Format(
CultureInfo.InvariantCulture,
@"
Sys.Application.add_load(function(sender, args) {{
var {0}_borderAnimation = new BorderAnimation('{1}');
var panelElement = document.getElementById('{0}');
if (args.get_isPartialLoad()) {{
{0}_borderAnimation.animate(panelElement);
}}
}})
",
updatePanel.ClientID,
ColorTranslator.ToHtml(BorderColor));





ScriptManager.RegisterStartupScript(
this,
typeof(UpdatePanelAnimationWithClientResource),
ClientID,
script,
true);
}
}
}
}










八、向AssemblyInfo.cs文件中添加如下行:




[assembly: System.Web.UI.WebResource("UpdateAnimate.UpdatePanelAnimation.js", "application/x-javascript")]




九、生成项目。







控件演示:




一、创建一个Ajax-enabled类型的网站项目。




二、向网站跟目录下添加bin目录。




三、从控件项目的bin\Debug或 bin\Release目录拷贝UpdateAnimate.dll到网站bin目录里。




四、替换Default.aspx的内容并运行程序:







<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>




<%@ Register TagPrefix="Samples" Namespace="UpdateAnimate" Assembly="UpdateAnimate" %>




"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">









ScriptReference






EnablePartialRendering="True"
runat="server">







ID="UpdatePanelAnimator1"
BorderColor="Green"
Animate="true"
UpdatePanelID="UpdatePanel1"
runat="server" >

UpdateMode="Conditional"
runat="server">

runat="server">










http://www.cnblogs.com/hblynn/archive/2007/02/01/637312.html









































添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.