任何人都可以幫我,因爲我需要在vb.net代碼中寫一個Javascript? 我的意思是我新vb.net編碼,我有一個動態創建表從Web服務,併爲該表我需要添加排序功能,這是在JavaScript代碼中,我需要添加此腳本動態創建的表 我試着用這樣的:如何在vb.net代碼中編寫java腳本?
oSB.Append("table.RegisterStartupScript('SCRIPTNAME', '<script language='javascript'>function tname(){alert('kk')};</script>')")
,但它似乎不工作atall。
此外,我試圖用這個
'oSB.Append("<script>$('[id^=tname] th').live('click',function(event){ alert('hello')}</script>")
我AJAX功能:創建
$.ajax({
type: "POST",
url: "Service1.asmx/GetRecipie",
contentType: "application/json; charset=utf-8",
data: "{'sDB':'" + sDB + "'}",
dataType: "json",
success: OnGetMemberSuccess,
failure: function (errMsg) {
$('#errorMessage').text(errMsg); //errorMessage is id of the div
}
});
function OnGetMemberSuccess(data, status) {
xistr = data.d.split(',');
$("#MemberDetails").html(data.d);
$('input[type=button]').attr('disabled', false);
}
}
表的代碼(web服務):
oSB.Append("<table id= '" + table_id + "' class='sortable' ><thead><tr><th class=border id='tname' >" + "Name" + "<img src='next.gif'/></th><th class=border>" + "Duration" + "</th><th class=border>" + "State" + "</th><th class=border>" + "Party" + "</th><th class=border>" + "Year" + "</th></tr></thead>")
sNameValue = dr("sName").ToString
sDurValue = dr("sDuration").ToString
sStateValue = dr("sState").ToString
sPartyValue = dr("sParty").ToString
sYearValue = dr("sYear").ToString
oSB.Append("<tbody id=tbodyid'>")
' oSB.Append("<tr id='trid'>")
oSB.Append("<tr>")
oSB.Append("<td id='tdid' class=border1>")
oSB.Append(sNameValue)
oSB.Append("</td>")
oSB.Append("<td class=border1>")
oSB.Append(sDurValue)
oSB.Append("</td>")
oSB.Append("<td id='td_state' class=border1>")
oSB.Append(sStateValue)
oSB.Append("</td>")
oSB.Append("<td class=border1>")
oSB.Append(sPartyValue)
oSB.Append("</td>")
oSB.Append("<td class=border1>")
oSB.Append(sYearValue)
oSB.Append("</td>")
oSB.Append("</tr>")
oSB.Append("</tbody>")
End While
dr.Close()
con.Close()
oSB.Append("</table>")
'MsgBox(table.ToString)
Debug.Print(oSB.ToString)
有人可以告訴我在哪裏我錯了嗎?
再次歡呼
請谷歌搜索嗎? – Swarne27