我有以下代码在列表中显示帖子标题作为超链接。点击此链接时,它应显示存储在ArrayList al中的帖子的其他详细信息。可以请帮我怎么做?
protected void Page_Load(object sender, EventArgs e)
{
DB ob = new DB();
string html = "";
ArrayList temp = new ArrayList();
DB.open();
ArrayList al = new ArrayList();
for (int i = 1; i <= 4; i++)
{
al.Add(ob.fetch_post(i));
temp = (ArrayList)al[i-1];
html = html + "<div class=\"spacer\"></div>" + " " + "<div id=\"Title\" +i+"\" class=\"title\">"+ "<a href=\"#\"/>" + temp[0] + "</a> </div>";
}
wrapper_title.InnerHtml = html;
}
我已将ajax功能包含在内,如下所示
$(document).ready(function () {
// Add the page method call as an onclick handler for the div.
$("#Title").click(function () {
$.ajax({
type: "POST",
url: "Default.aspx/display",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
// Replace the div's content with the page method's return.
$("#sidebar1").text(msg.d);
}
});
});
});
现在我遇到的问题是动态地当从Title1到Title4创建div id时我不知道如何调用上面的AJAX函数。并且还帮助我将ArrayList al作为参数从Ajax传递到显示C#的函数。