1、jquery操作frame元素
1.1在父窗口中操作 选中IFRAME中的所有单选钮
$(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");
1.2 在IFRAME中操作 选中父窗口中的所有单选钮
$(window.parent.document).find("input[@type='radio']").attr("checked","true");
1.3 $(document.getElementById('iframeId').contentWindow.document.body).htm()
1.4 显示frame中元素:$("#testId", document.frames["iframename"].document).html();
2、http://www.jb51.net/article/24101.htm 闭包可以用在许多地方。它的最大用处有两个,一个是前面提到的可以读取函数内部的变量,另一个就是让这些变量的值始终保持在内存中。
3、后台执行js代码:
当使用了ScriptManager后:System.Web.UI.ScriptManager.RegisterStartupScript(control, type, "NULL", script, addScriptTags)
没有使用ScriptManager:Page.ClientScript.RegisterStartupScript(ClientScript.GetType(), "key", script);
4、将普通页面的方法公布为WebMethod,以Javascript形式访问。
5、webMethod的命名空间为System.Web.Services;;
6、jquery之get,post,ajax:http://www.cnblogs.com/mqingqing123/archive/2009/10/16/1584727.html
7、js中this只的是调用函数的那个对象;
8、js中call和apply的区别:对于apply和call两者在作用上是相同的,但两者在参数上有区别的。
对于第一个参数意义都一样,但对第二个参数:
apply传入的是一个参数数组,也就是将多个参数组合成为一个数组传入,而call则作为call的参数传入(从第二个参数开始)。
如 func.call(func1,var1,var2,var3)对应的apply写法为:func.apply(func1,[var1,var2,var3])
同时使用apply的好处是可以直接将当前函数的arguments对象作为apply的第二个参数传入
9、object的实例不能访问prototype属性
10、在asp.net配置文件中authorization(授权)和authentication(认证)拼写不要错;
11、js的一个简单结构:
//定义空父类(负责定义函数)
window.abstractCookie = {};
abstractCookie.init = function () {
//TODO:
return this;
};
//父类函数
abstractCookie.set = function () {
alert(today.getTime());
document.cookie = this.key + "=" + escape(this.value) + ";";
};
abstractCookie.get = function () {
var begin = document.cookie.indexOf(this.key);
if (begin == -1) return null;
begin = this.key.length + 1;
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = document.cookie.length;
}
var val = document.cookie.substring(begin, end);
return unescape(val);
};
//定义子类(只负责赋值)
window.Tcookie = function (options) {
this.key =options.key || "usrkey";
this.value =options.value || "usrvalue";
};
jQuery.extend(Tcookie.prototype, abstractCookie); //继承abstractCookie
//传说中的静态函数
window.Tcookie.create = function () {
var inst = new Tcookie(option);
return inst.init();
};
jQuery(function () {
var options = {key:"username",value:"glm"};
var cook = new Tcookie(options);
cook.set();
if (cook.get() != "") {
alert("welcome back " + cook.get());
}
});
12、var arr = XX.match(****);返回的数组arr[0]是完整匹配结果,其余的为子表达式匹配结果;
子表达式允许嵌套,而且允许多层嵌套,嵌套层次在理论上没有限制。
在表达式 ((A)(B(C))) 中,存在以下几个子表达式:
((A)(B(C)))
(A)
(B(C))
(C)
共4个,第0个始终代表整个表达式。在后面的回溯引用中会介绍到通过\n(n是子表式的编号)来引用子表达式。
13、npoi是导出excel,word,ppt到本地的好帮手,没有安装office的要求;
14、profile比session要强很多;
15、工厂模式、策略者模式、观察者模式;
16、JQuery获取标签名居然是这样jQuery("a").attr("tagName");
17、前台获取session的值,在jQuery(function(){})中获取到了;
18、js获取服务器控件:document.getElementById('<%=TextBox1.ClientID %>')
jquery:jQuery('#'+'<%=TextBox1.ClientID %>').val(val);
19、ie不能识别firstChild.nodeValue,火狐不能识别innerText;
20、页面使用了ScriptManager,则js循环获取后台的变量<%=data %>,如果页面不回发,是获取不到更新的值的。(可以用$.ajax解决)
21、修改了配置文件就可以使用Profile了:http://blog.csdn.net/adenfeng/article/details/5600830
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms"/>
<anonymousIdentification enabled="true"/>
<profile>
<properties>
<add name="FirstName" defaultValue="??" allowAnonymous="true"/>
<add name="LastName" defaultValue="??" allowAnonymous="true"/>
<add name="PageVisits" type="Int32" allowAnonymous="true"/>
</properties>
</profile>
</system.web>
22、异步调用IAsyncResult的使用:http://www.cnblogs.com/inforasc/archive/2009/10/21/1587756.html
23、在静态函数中更新控件内容:
页面类传委托,静态类通过委托更新,比如
class MyClass
{
public static void foo(Action<string> OnUpdateText)
{
...
OnUpdateText("hello world");
}
}
页面类调用
class Default : Page
{
public void Page_Load()
{
MyClass.foo(s => textBox1.Text = s);
}
}
24、如果想让Timer只更新一个控件,需要把此控件用UpdatePanel套住,然后外层的UpdatePanel属性UpdateMode=conditional,ChildrenAsTriggers=false;
25、button点击时,先执行前台代码,后执行后台代码:在page_Load事件中button.Attribute.add("onclick","return jsfunc");注意jsfunc一定要返回true;否则后台就不执行了。
26、显示星期几:DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn"))
27、正则表达式非获取匹配、获取匹配、正向预查、负正向预查、反向预查、负反向预查
28、常用泛型委托Action<T>,Func<T>,Predicate<T>