jQery -- 我的记录
选择嵌套表格行
<title>无标题文档</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//浏览会解析时会给table里面添加一个tbody元素。你可以用DOM浏览器查看一下。
$("#aa>tbody>tr:eql(0)").css("backgroundColor","#CCCCCC");
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//浏览会解析时会给table里面添加一个tbody元素。你可以用DOM浏览器查看一下。
$("#aa>tbody>tr:eql(0)").css("backgroundColor","#CCCCCC");
//选择表格aa下的第一行
});
</script>
<style type="text/css">
#bb {
width:200px;
height:50px;
background-color:#99CCFF;
margin:20px;
}
</style>
</head>
<body>
<table id="aa">
<tr>
<td>
<table id="bb">
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table id="bb">
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
});
</script>
<style type="text/css">
#bb {
width:200px;
height:50px;
background-color:#99CCFF;
margin:20px;
}
</style>
</head>
<body>
<table id="aa">
<tr>
<td>
<table id="bb">
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table id="bb">
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Ajax -- post 带参数调后台方法
function DoAjax(){
$.post(
"AjaxTest.aspx",
{txt: "参数"},
function(data){
alert(data);
}
);
}
void Page_Load(object sender , EventArgs e)
{
string s = Request.Form["txt"];
Response.Write("返回数据");
}
$.post(
"AjaxTest.aspx",
{txt: "参数"},
function(data){
alert(data);
}
);
}
void Page_Load(object sender , EventArgs e)
{
string s = Request.Form["txt"];
Response.Write("返回数据");
}
var value = “林”
$.get("./AjaxHandler.aspx?value=" + escape(value), function(data) {});
escape : 转换为 UTF-8
unescape: 解码
$.get("./AjaxHandler.aspx?value=" + escape(value), function(data) {});
escape : 转换为 UTF-8
unescape: 解码
遍历表格
说明: 遍历表格相关列,与新增数据比较,提示是否重复
function duplicateCheck(usertype, username) {
var result = true;
$("#tbPermission>tbody>tr").each(function() {
var _usertype = $.trim($(this).find("td:eq(0)").text());
var _username = $.trim($(this).find("td:eq(1)").text());
if (usertype == _usertype && username == _username ) {
alert('数据有重复,请检查!');
result = false;
return false;
}
});
return result ;
}
function duplicateCheck(usertype, username) {
var result = true;
$("#tbPermission>tbody>tr").each(function() {
var _usertype = $.trim($(this).find("td:eq(0)").text());
var _username = $.trim($(this).find("td:eq(1)").text());
if (usertype == _usertype && username == _username ) {
alert('数据有重复,请检查!');
result = false;
return false;
}
});
return result ;
}
autocomplete -- 自动完成插件
<script type="text/javascript">
$(document).ready(function(){
$("#<%=txtUserName.ClientID %>").autocomplete('<%= this.ResolveUrl("~/apps/security/controls/autocompletehandler.aspx") %>', {
autoFill: true,
multiple: <%=IsSingleSelected?"false":"true" %>,
formatItem: function(row, i, max) {
return row[0] + "[" + row[1] + "]";
},
formatMatch: function(row, i, max) {
return row[0] + "[" + row[1] + "]";
},
formatResult: function(row) {
return row[1];
}
});
});
</script>
protected void Page_Load(object sender, EventArgs e)
{
StringBuilder builder = new StringBuilder();
if (!this.IsPostBack)
{
if (!string.IsNullOrEmpty(Request.QueryString["q"]))
{
string q = Request.QueryString["q"];
IList<UserInfo> userList = userService.GetUsersLikeName(q);
foreach (UserInfo info in userList)
{
builder.AppendFormat("{0}|{1}\n", info.RealName, info.UserName);
}
//if (builder.Length > 2)
// builder.Remove(0, builder.Length - 2);
}
}
Response.Clear();
Response.Write(builder.ToString());
Response.End();
}
$(document).ready(function(){
$("#<%=txtUserName.ClientID %>").autocomplete('<%= this.ResolveUrl("~/apps/security/controls/autocompletehandler.aspx") %>', {
autoFill: true,
multiple: <%=IsSingleSelected?"false":"true" %>,
formatItem: function(row, i, max) {
return row[0] + "[" + row[1] + "]";
},
formatMatch: function(row, i, max) {
return row[0] + "[" + row[1] + "]";
},
formatResult: function(row) {
return row[1];
}
});
});
</script>
protected void Page_Load(object sender, EventArgs e)
{
StringBuilder builder = new StringBuilder();
if (!this.IsPostBack)
{
if (!string.IsNullOrEmpty(Request.QueryString["q"]))
{
string q = Request.QueryString["q"];
IList<UserInfo> userList = userService.GetUsersLikeName(q);
foreach (UserInfo info in userList)
{
builder.AppendFormat("{0}|{1}\n", info.RealName, info.UserName);
}
//if (builder.Length > 2)
// builder.Remove(0, builder.Length - 2);
}
}
Response.Clear();
Response.Write(builder.ToString());
Response.End();
}
posted on 2009-12-14 00:03 snowleopard 阅读(389) 评论(0) 收藏 举报

浙公网安备 33010602011771号