javascript,jquery,c#,Sql 常用小方法(陆续增加)

把自己平时常用的一些小方法就记下来!

C#  <%#Eval("CallTime","{0:d}")%>  格式化日期为年月日

Jquery 获取

Radio 选定值: $('input[@name=relation][@checked]').val();

1.4  $('input[name=relation][checked]').val();

火狐下用法:  $(':radio[name=topic][checked]').val(); checkbox类似,所以为了火狐IE都可以正常必须采取这样取值。

获取DropDownList的值 $('#DropDownList2').val();

 $("#ddlCityName").find('option:selected').text(); 

原味javascript 获取值:例如 <select id="Select5">
                            <option value="1">555</option>
                            <option value="2">888</option>
                             </select>

可用如下方法获取value和innerText。

var objs= document.getElementById("Select5");

objs.options[objs.selectedIndex].value;

Span 获取值用$("#sqlString").text();这个方法!

&&为与关系,||为或关系!

css 左右居中 margin-left:auto; margin-right:auto;

左右垂直居中  position:absolute; top:50%; left:50%; margin:-50px 0 0 -150px; width:300px; height:100px; border:solid 1px blue; margin-bottom:50%;

关于GridView this.GridView1.HeaderRow.Cells.Count;  如果是自动绑定的话获取数据显示的头,必须用这个方法,因为this.GridView1.Columns.Count是空的!本来自动绑定的话显示的数据库的字段,现在要显示汉字的,所以在这个部分来操作和更改。this.GridView1.HeaderRow.Cells[i].Text

jquery

1.4.1API http://jquery-api-zh-cn.googlecode.com/svn/trunk/xml/jqueryapi.xml

1.3 API http://jquery-api-zh-cn.googlecode.com/svn/trunk/index.html

1.2 API http://www.phpx.com/man/jQuery/

var bln = window.confirm("确认要删吗?");
    if(bln==true){}

sql求时间差 datediff(day,CreatedDate,getdate()),获取cofig 数据库字符串:System.Configuration.ConfigurationSettings.AppSettings["strConn"]

Repeater中根据结果显示不同结果的三元表达式

<%#Eval("IsDelete").ToString() =="False" ? "<input id=""IsDelete"" onclick=""MyDelete('" + Eval("PostID") + "','1')"" type='button' value='隐藏回复' />" : "<input id=""Button5"" color:Red;"" onclick=""MyDelete('" + Eval("PostID") + "','0')"" type=""button"" value=""解除隐藏"" />"%></td><td><%#Eval("Contents")%></td><td><%#Eval("IsDelete")%>

Velocity的基本命令

使用如下命令金额图对启动、停止、重启服务器集群:

Start-CacheCluster 
Stop-CacheCluster
Restart-CacheCluster

使用如下命令可以启动、停止缓存宿主、获取命名缓存、获取缓存分区等:

Get-CacheHost 
Get-CacheConfig
Set-CacheConfig
Start-CacheHost
Stop-CacheHost
Get-CacheStatistics
Get-Cache
Get-CacheRegion
页面添加蒙板CSS代码:
.overlay {display:none; position:fixed; _position:absolute; left:0; top:0; width:100%; height:100%; z-index:9990;
_height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
background-color:#aaa; opacity:0.3; filter:Alpha(Opacity=30);}
常用验证代码
$(".rightSide form").validate({
errorElement: "li",
errorPlacement: function(error, element) {
error.insertBefore( element.parent().parent() );
},
rules: {
username: {
required: true,
rangelength: [2,14]
},
email: {
required: true,
email: true
},
password: {
required:true,
rangelength: [2,16]
},
confirmPwd: {
required: true,
equalTo:"#txtUserPwd"
},
policy: {
required: true
}
},
messages: {
confirmPwd: {
equalTo:"请再次输入相同的密码"
}
}

});
事件冒泡
$("#Composite_Radio").click(function(event) {
var nElement = $(event.target);
if (nElement.attr("type") == 'radio' && nElement[0].tagName == 'INPUT') {
$("#Composite_Risk").html(Fun.type[nElement.val()]);
}
});
看table的结果集:table.Rows.list

posted @ 2009-02-03 14:33  bluenan  阅读(1222)  评论(2编辑  收藏  举报