我做的是新闻发布系统已经生成的静态页面了 但是想在新闻标题下添加 "我要评论 " 我做的是新闻发布系统已经生成的静态页面了 但是想在新闻标题下添加 "我要评论 " 点击后自动连接到该标题对应的评论数据库显示出来...然后也可以提交评论, 但是不知道在 "模板页 "里怎么做?还是该怎么做呢?我是新手,希望能讲明白些哦!谢谢~~呵呵~~~就像 这个网页上 “我要评论(条)” 这样的动态连接可以吗?http://news.qq.com/a/20101025/000563.htm?pgv_ref=aio 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 评论的编辑框、按钮 放在 form表单中, 通过action指定到提交的页面。 楼上的...具体的话该怎么做呢?可以告诉我吗?我只做了一个动态生成静态页面的,然后想添加就不懂了~我的动态生成静态页面代码如下...</head><body style="text-align: center; font-family: 宋体;"> <!--<table border="1" cellpadding="0" cellspacing="0" style="width: 767px; height: 327px"> <tr> <td align="center" colspan="2"> <span style="font-size: 16pt"><strong> $Title$</strong></span></td> </tr> <tr> <td align="center" colspan="2"> <span style="font-size: 10pt"> 新闻类别:[$NewsKind$] 发布时间:[$PubTime$] 来源:[$NewSource$]</span></td> </tr> <tr> <td align="center" colspan="2" style="height: 11px"> </td> </tr> <tr> <td colspan="2" style="height: 204px"> $NewsBody$</td></tr><tr> <td style="WIDTH: 100px; height: 19px;"> </td><td style="WIDTH: 100px; height: 19px; text-align: right;" > 发布人:$UserName$</td></tr></table>--> <table width="594" border="0" cellpadding="3" cellspacing="3" class="FontGray"> <tr> <td background="../../images/main/news_50.gif" style="height: 17px"> </td> </tr> <tr> <td id="Main" runat="server"><div id="bt" style="text-align: center"> <strong><span style="font-size: 16pt">$Title$</span></strong></div> <div id="msg" style="text-align: center"> <span style="font-size: 9pt">新闻类别:[$NewsKind$] 发布时间:[$PubTime$] 来源:[$NewSource$]<br /> 我要评论($Comment$)<br /> </span><hr style="width: 545px" /></div> <div id="new_content" style="text-align: center"> <div style="text-align: left"> $NewsBody$</div> <div style="text-align: right"> <br /> <hr id="HR1" language="javascript" onclick="return HR1_onclick()" style="border-right: silver 3px dotted; border-top: silver 3px dotted; border-left: silver 3px dotted; width: 221px; border-bottom: silver 3px dotted" /> </div> <div style="text-align: right" ><span style="font-size: 10pt">发布人:$UserName$</span></div></div></td> </tr> <tr> <td height="46" background="../../images/main/news_50.gif"> </td> </tr> <tr> <td id="Td1" runat="server"> </td> </tr> </table> </body></html> 楼上的...具体的话该怎么做呢?可以告诉我吗?我只做了一个动态生成静态页面的,然后想添加就不懂了~我的动态生成静态页面代码如下...</head><body style="text-align: center; font-family: 宋体;"> <!--<table border="1" cellpadding="0" cellspacing="0" style="width: 767px; height: 327px"> <tr> <td align="center" colspan="2"> <span style="font-size: 16pt"><strong> $Title$</strong></span></td> </tr> <tr> <td align="center" colspan="2"> <span style="font-size: 10pt"> 新闻类别:[$NewsKind$] 发布时间:[$PubTime$] 来源:[$NewSource$]</span></td> </tr> <tr> <td align="center" colspan="2" style="height: 11px"> </td> </tr> <tr> <td colspan="2" style="height: 204px"> $NewsBody$</td></tr><tr> <td style="WIDTH: 100px; height: 19px;"> </td><td style="WIDTH: 100px; height: 19px; text-align: right;" > 发布人:$UserName$</td></tr></table>--> <table width="594" border="0" cellpadding="3" cellspacing="3" class="FontGray"> <tr> <td background="../../images/main/news_50.gif" style="height: 17px"> </td> </tr> <tr> <td id="Main" runat="server"><div id="bt" style="text-align: center"> <strong><span style="font-size: 16pt">$Title$</span></strong></div> <div id="msg" style="text-align: center"> <span style="font-size: 9pt">新闻类别:[$NewsKind$] 发布时间:[$PubTime$] 来源:[$NewSource$]<br /> 我要评论($Comment$)<br /> </span><hr style="width: 545px" /></div> <div id="new_content" style="text-align: center"> <div style="text-align: left"> $NewsBody$</div> <div style="text-align: right"> <br /> <hr id="HR1" language="javascript" onclick="return HR1_onclick()" style="border-right: silver 3px dotted; border-top: silver 3px dotted; border-left: silver 3px dotted; width: 221px; border-bottom: silver 3px dotted" /> </div> <div style="text-align: right" ><span style="font-size: 10pt">发布人:$UserName$</span></div></div></td> </tr> <tr> <td height="46" background="../../images/main/news_50.gif"> </td> </tr> <tr> <td id="Td1" runat="server"> </td> </tr> </table> </body></html> 给楼主说个思路。您的新闻页面的静态页面上如果要显示评论的个数,可以通过ajax的方式来实现。每个静态的新闻页面其实对应的有一个唯一标识(Id),可以通过ajax方式读取该新闻Id对应的评论数。至于添加评论,可以传递新闻Id,然后连接到评论页面。在该页面完成评论添加,如果你不清楚如何在一个静态页面提交表单。建议google一下get和post传值。 嗯~正如楼上您所说的那样...可是我不太懂怎么弄耶 也查了好多资料还是查不到...能不能给点详细些的呢?AJAX我没学过...但是也有接触到一点~~ 静态页面评论的话你嵌个iframe,生成静态的时候同时把文章id传给iframe链接的动态页面然后剩下的都很简单了 通过iframe嵌套页面或通过ajax传值 2:通过ajax,同样也是在生成的时候把id传给ajax方法。主要是把id传进去,有了id都很方便了 如果用iframe你生成静态页是用模版的,可以在模版里面把嵌套个iframe<iframe src='xx.aspx?ID=把id传到这里' scroll="no" frameborder='0'>然后在xx.aspx页面if(!string.isnullorempty(request.querystring["id"]))int id = convert.toint32(request.querystring["id"]);获取到id之后就是插入了如果用ajaxfunction insertMsg(id){ url:"xx.ashx", type:"post", data:"ID="+id+"&title="+标题的值+"", success:function(result){ alert("评论成功"); }, error:function(resMsg){alert(resMsg)}}onclick="insertMsg(生成的时候把id传到这里)"之后在xx.ashx页面获取idint id = context.request.form["ID"]string title = context.request.form["title"]之后就是插入了 两种方法,一种是iframe,一种是ajax。lz先用用iframe好了! 你好啊~~我昨晚试了 不过后来断电了,刚刚弄了...貌似还是搞不定耶~~是不是只在模板上用IFARAM就可以了呢?还是还要在对应的动态生成静态页面时xx.aspx.cs上还要写些什么呢? 请问高手!!有高手吗?我做了form的点击时可以跳转到对应的页面了~~但是在静态页面上无法显示数据上的留言评论的条数!~~请问该怎么来实现呢? 通过iframe嵌套页面或通过ajax传值JS调用WebService 都可以 在IFAMRE页面找到父窗体。通过JS改变评论数。 这里是ajax的例子,input type="button" onclick="send()"$.ajax({ url:"default.ashx type:"post", dataType:"html", data:"Title="+$("#title").val()+"&Content="+$("#content").val()+"",//这里把留言的标题内容什么的提交过去, success:function(result){ if(result=="true"){ alert("评论成功!"); window.location.reload(); } else alert("评论失败!") }, error:function(resMsg){alert(resMsg)}})//default.ashxstring title = Convert.Toint32(Request.Form["Title"]);string content= Convert.Toint32(Request.Form["Content"]);int result = SqlHelper.ExecuteNonquery("insert into table(title,content) values('"+title+"','"+content+"')");//这里为了方便直接拼接了,建议lz用参数化形式if(result==1){ Httpcontext.Response.writer("true"); Httpcontext.REsponse.end();}else{ Httpcontext.Response.writer("false"); Httpcontext.REsponse.end();} function send(){ $.ajax({ url:"default.ashx type:"post", dataType:"html", data:"Title="+$("#title").val()+"&Content="+$("#content").val()+"",<--这里把留言的标题内容什么的提交过去--> success:function(result){ if(result=="true"){ alert("评论成功!"); window.location.reload(); } else alert("评论失败!") }, error:function(resMsg){alert(resMsg)}})} 你可以在这里 Httpcontext.Response.writer("true");返回给js的时候把条数统计出来判断下if(result==1)//评论成功{ //这里你查找对该新闻统计评论条数 //int count = //...取得评论条数 Httpcontext.Response.writer(count); Httpcontext.REsponse.end();}else//插入失败返回0{ Httpcontext.Response.writer("0"); Httpcontext.REsponse.end();} success:function(result){ if(result!=""){ document.getElementById("zz").html=result; alert("评论成功!"); } else alert("评论失败!") }, success:function(result){ if(result!="0"){ document.getElementById("zz").html=result; alert("评论成功!"); } else alert("评论失败!") }, 就是在你本来的静态模版放几个input type="text"控件看你要标题内容还是什么,然后一个input type="button"按狃这样生成静态页的时候每个页面都有留言的地方然后通过点击button按狃,用ajax提交过去方法都在上面了 Sql Server插入数据问题 为什么我在前台上传了六张图片 只显示一张啊? 服务器上假设好的网站,为什么打开会报错? GridView 三层里面怎样删除行啊~? ASP.NET程序如何取消对asp文件的禁止? 使用连接检测用户名 在线等 51aspx上下的办公自动化系统OATest 出现了个问题 哪位高手帮忙解决下 自定义控件怎样在设计时页面上添加子控件? 我只有这些分了,希望有心人能够帮助我,谢谢 TabStrip,Multipage控件怎么绑定数据? 在网页中,如何实现把txt文件导入到oracle 关于网址很怪的问题
我的动态生成静态页面代码如下...
</head>
<body style="text-align: center; font-family: 宋体;">
<!--<table border="1" cellpadding="0" cellspacing="0" style="width: 767px; height: 327px">
<tr>
<td align="center" colspan="2">
<span style="font-size: 16pt"><strong>
$Title$</strong></span></td>
</tr>
<tr>
<td align="center" colspan="2">
<span style="font-size: 10pt"> 新闻类别:[$NewsKind$] 发布时间:[$PubTime$] 来源:[$NewSource$]</span></td>
</tr>
<tr>
<td align="center" colspan="2" style="height: 11px">
</td>
</tr>
<tr>
<td colspan="2" style="height: 204px">
$NewsBody$</td></tr><tr>
<td style="WIDTH: 100px; height: 19px;">
</td><td style="WIDTH: 100px; height: 19px; text-align: right;" >
发布人:$UserName$</td></tr></table>-->
<table width="594" border="0" cellpadding="3" cellspacing="3" class="FontGray">
<tr>
<td background="../../images/main/news_50.gif" style="height: 17px">
</td>
</tr>
<tr>
<td id="Main" runat="server"><div id="bt" style="text-align: center">
<strong><span style="font-size: 16pt">$Title$</span></strong></div>
<div id="msg" style="text-align: center">
<span style="font-size: 9pt">新闻类别:[$NewsKind$] 发布时间:[$PubTime$] 来源:[$NewSource$]<br />
我要评论($Comment$)<br />
</span><hr style="width: 545px" /></div>
<div id="new_content" style="text-align: center">
<div style="text-align: left">
$NewsBody$</div>
<div style="text-align: right">
<br />
<hr id="HR1" language="javascript" onclick="return HR1_onclick()" style="border-right: silver 3px dotted; border-top: silver 3px dotted; border-left: silver 3px dotted; width: 221px; border-bottom: silver 3px dotted" />
</div>
<div style="text-align: right" ><span style="font-size: 10pt">发布人:$UserName$</span></div></div></td>
</tr>
<tr>
<td height="46" background="../../images/main/news_50.gif"> </td>
</tr>
<tr>
<td id="Td1" runat="server"> </td>
</tr>
</table>
</body>
</html>
我的动态生成静态页面代码如下...
</head>
<body style="text-align: center; font-family: 宋体;">
<!--<table border="1" cellpadding="0" cellspacing="0" style="width: 767px; height: 327px">
<tr>
<td align="center" colspan="2">
<span style="font-size: 16pt"><strong>
$Title$</strong></span></td>
</tr>
<tr>
<td align="center" colspan="2">
<span style="font-size: 10pt"> 新闻类别:[$NewsKind$] 发布时间:[$PubTime$] 来源:[$NewSource$]</span></td>
</tr>
<tr>
<td align="center" colspan="2" style="height: 11px">
</td>
</tr>
<tr>
<td colspan="2" style="height: 204px">
$NewsBody$</td></tr><tr>
<td style="WIDTH: 100px; height: 19px;">
</td><td style="WIDTH: 100px; height: 19px; text-align: right;" >
发布人:$UserName$</td></tr></table>-->
<table width="594" border="0" cellpadding="3" cellspacing="3" class="FontGray">
<tr>
<td background="../../images/main/news_50.gif" style="height: 17px">
</td>
</tr>
<tr>
<td id="Main" runat="server"><div id="bt" style="text-align: center">
<strong><span style="font-size: 16pt">$Title$</span></strong></div>
<div id="msg" style="text-align: center">
<span style="font-size: 9pt">新闻类别:[$NewsKind$] 发布时间:[$PubTime$] 来源:[$NewSource$]<br />
我要评论($Comment$)<br />
</span><hr style="width: 545px" /></div>
<div id="new_content" style="text-align: center">
<div style="text-align: left">
$NewsBody$</div>
<div style="text-align: right">
<br />
<hr id="HR1" language="javascript" onclick="return HR1_onclick()" style="border-right: silver 3px dotted; border-top: silver 3px dotted; border-left: silver 3px dotted; width: 221px; border-bottom: silver 3px dotted" />
</div>
<div style="text-align: right" ><span style="font-size: 10pt">发布人:$UserName$</span></div></div></td>
</tr>
<tr>
<td height="46" background="../../images/main/news_50.gif"> </td>
</tr>
<tr>
<td id="Td1" runat="server"> </td>
</tr>
</table>
</body>
</html>
您的新闻页面的静态页面上如果要显示评论的个数,可以通过ajax的方式来实现。每个静态的新闻页面其实对应的有一个唯一标识(Id),可以通过ajax方式读取该新闻Id对应的评论数。至于添加评论,可以传递新闻Id,然后连接到评论页面。在该页面完成评论添加,如果你不清楚如何在一个静态页面提交表单。建议google一下get和post传值。
然后剩下的都很简单了
或通过ajax传值
主要是把id传进去,有了id都很方便了
你生成静态页是用模版的,可以在模版里面把嵌套个iframe
<iframe src='xx.aspx?ID=把id传到这里' scroll="no" frameborder='0'>
然后在xx.aspx页面
if(!string.isnullorempty(request.querystring["id"]))
int id = convert.toint32(request.querystring["id"]);
获取到id之后就是插入了
如果用ajax
function insertMsg(id)
{
url:"xx.ashx",
type:"post",
data:"ID="+id+"&title="+标题的值+"",
success:function(result){
alert("评论成功");
},
error:function(resMsg){alert(resMsg)}
}
onclick="insertMsg(生成的时候把id传到这里)"
之后在xx.ashx页面获取id
int id = context.request.form["ID"]
string title = context.request.form["title"]
之后就是插入了
lz先用用iframe好了!
你好啊~~我昨晚试了 不过后来断电了,刚刚弄了...貌似还是搞不定耶~~是不是只在模板上用IFARAM就可以了呢?还是还要在对应的动态生成静态页面时xx.aspx.cs上还要写些什么呢?
或通过ajax传值JS调用WebService 都可以
通过JS改变评论数。
input type="button" onclick="send()"$.ajax({
url:"default.ashx
type:"post",
dataType:"html",
data:"Title="+$("#title").val()+"&Content="+$("#content").val()+"",//这里把留言的标题内容什么的提交过去,
success:function(result){
if(result=="true"){
alert("评论成功!");
window.location.reload();
}
else
alert("评论失败!")
},
error:function(resMsg){alert(resMsg)}
})//default.ashx
string title = Convert.Toint32(Request.Form["Title"]);
string content= Convert.Toint32(Request.Form["Content"]);
int result = SqlHelper.ExecuteNonquery("insert into table(title,content) values('"+title+"','"+content+"')");//这里为了方便直接拼接了,建议lz用参数化形式
if(result==1)
{
Httpcontext.Response.writer("true");
Httpcontext.REsponse.end();
}
else
{
Httpcontext.Response.writer("false");
Httpcontext.REsponse.end();}
function send(){
$.ajax({
url:"default.ashx
type:"post",
dataType:"html",
data:"Title="+$("#title").val()+"&Content="+$("#content").val()+"",<--这里把留言的标题内容什么的提交过去-->
success:function(result){
if(result=="true"){
alert("评论成功!");
window.location.reload();
}
else
alert("评论失败!")
},
error:function(resMsg){alert(resMsg)}
})
}
{
//这里你查找对该新闻统计评论条数
//int count = //...取得评论条数
Httpcontext.Response.writer(count);
Httpcontext.REsponse.end();
}
else//插入失败返回0
{
Httpcontext.Response.writer("0");
Httpcontext.REsponse.end();}
success:function(result){
if(result!=""){
document.getElementById("zz").html=result;
alert("评论成功!");
}
else
alert("评论失败!")
},
if(result!="0"){
document.getElementById("zz").html=result;
alert("评论成功!");
}
else
alert("评论失败!")
},
看你要标题内容还是什么,然后一个input type="button"按狃
这样生成静态页的时候每个页面都有留言的地方
然后通过点击button按狃,用ajax提交过去
方法都在上面了