小記

1. Jquery 取服務器控件的ID問題web

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

若將其放入用戶控件中或繼承自母版頁的頁面中,其ID值前面會自動加上其餘值,變成一長串(如:column0_webcontrol_hidweb), 此時得取其ClientID,
JS中:服務器

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

Jquery中能夠用:this

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

2. $(this).attr('checked')在不一樣版本的Jquery中選中和未選中返回值的問題
   原來Jquery v1.6之後$(this).attr('checked')就返回checked和undefined,spa

   v1.6之前返回true和false, v1.6之後能夠使用$(this).is(':checked')或者$(this).prop('checked')來返回true和falsecode

 

3. JS中動態拼裝JSON對象server

    若要拼裝成相似對象[對象

                                 {blog

                                       "Name": "aaa",繼承

                                       "Contry": "China",seo

                                       "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.

相關文章
相關標籤/搜索