小记

1. Jquery 取服务器控件的ID问题

<input type="hidden" id="hidweb" runat="server" />

若将其放入用户控件中或继承自母版页的页面中,其ID值前面会自动加上其他值,变成一长串(如:column0_webcontrol_hidweb), 此时得取其ClientID,
JS中:

document.getElementById("<%=hidweb.ClientID %>");

Jquery中可以用:

$j('*[id$=hidweb]').val();

2. $(this).attr('checked')在不同版本的Jquery中选中和未选中返回值的问题
   原来Jquery v1.6以后$(this).attr('checked')就返回checked和undefined,

   v1.6以前返回true和false, v1.6以后可以使用$(this).is(':checked')或者$(this).prop('checked')来返回true和false

 

3. JS中动态拼装JSON对象

    若要拼装成类似对象[

                                 {

                                       "Name": "aaa",

                                       "Contry": "China",

                                       "Area": ["AA", "BB"]

                                 }

                             ]

    可以如下:

    

var peoples =[];
var people = {};
var area = []; 

people['Name'] = "aaa";
people['Country'] = "China";
area.push('AA');
area.push('BB');
people['Area'] = area;

peoples.push(people);

// JSON 对象转成字符串
var objectString = JSON.stringify(peoples); // 字符串转成JSON 对象
var
people = JSON.parse(objectString);

 

4. 关于Response.Redirect的 false 与 true

  Response.Redirect(URL, false) :    - Client is redirected to a new page and the current page on the server will keep processing ahead.

  Response.Redirect(URL, true) :    - Client is redirected to a new page but the processing of the current page is aborted.

posted on 2013-11-08 16:51  Gcam  阅读(183)  评论(0编辑  收藏  举报

导航