单击其链接显示特定帖子的详细信息 [英] Displaying Details of Particular post on clicking its link

查看:101
本文介绍了单击其链接显示特定帖子的详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码在列表中显示帖子标题作为超链接。点击此链接时,它应显示存储在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 \class = \title+ i +\> +< a href = \#\/> + temp [0] +< / a>< / div>;
}
wrapper_title.InnerHtml = html;
}



我已经包含了ajax功能如下

 $(文件) .ready(function(){
//将页面方法调用添加为div的onclick处理程序。
$(#Title)。click(function(){
$。 ajax({
类型:POST,
url:Default.aspx / __ sample,
data:{},
contentType:application / json; charset = utf-8,
dataType:json,
success:function(msg){
//用页面方法的返回替换div的内容。
$( #sidebar1)。text(msg.d);
}
});
});
});

解决方案

(document).ready(function(){
//将页面方法调用添加为div的onclick处理程序。


< blockquote>(#Title)。click(function(){


.ajax({
type:POST,
url:Default.aspx / __ sample,
data:{},
contentType:application / json; charset = utf-8,
dataType:json,
success:function(msg){
//用页面方法的返回替换div的内容。


I have the following code which displays Title of posts as hyperlinks in a list.. On clicking this link it should display other details of post which is stored in ArrayList al. Could pls help me how to do this ?

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\" class=\"title" + i + "\">" + "<a href=\"#\"/>" + temp[0] + "</a> </div>";
    }
    wrapper_title.InnerHtml = html;
}


I have included the ajax function as follows

$(document).ready(function () {
    // Add the page method call as an onclick handler for the div.
    $("#Title").click(function () {
        $.ajax({
            type: "POST",
            url: "Default.aspx/__sample",
            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);
            }
        });
    });
});

解决方案

(document).ready(function () { // Add the page method call as an onclick handler for the div.


("#Title").click(function () {


.ajax({ type: "POST", url: "Default.aspx/__sample", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { // Replace the div's content with the page method's return.


这篇关于单击其链接显示特定帖子的详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆