写的一个功能是文章评论,按钮是在一个div层里面的,单击评论,显示一个层,层里是评论内容,和提交评论按钮。现在按钮第一次单击的时候正确的,但是在单击就没效果了,直接没反应了,搞了一晚上也没看出是哪里错了,麻烦大家看下了,搞死我了。//Aritical.aspx
<%@ Page Language="C#" MasterPageFile="~/View/Site.Master" AutoEventWireup="true"
CodeBehind="Aritical.aspx.cs" Inherits="Web.View.WebForm1" Title="无标题页" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="aritical">
<div style="width: 670px; border: solid 1px #AECBE7; background-color: #F6FCFF; float: left;
margin: 3px 0 0 3px; padding: 10px;">
<h1>
<asp:Label ID="lbTitle" runat="server" Text=""></asp:Label>
</h1>
<asp:Label ID="lbInfos" runat="server" Text=""></asp:Label>
<hr />
<div style="text-align: left; line-height: 120%;">
<asp:Label ID="lbDetails" runat="server" Text="很抱歉,您找的文章不存在或已经被删除!"></asp:Label>
</div>
</div>
<div style="width: 248px; float: right; text-align: center; margin: 3px 2px 0px 0px;">
<img src="/UploadFile/adimgs/gz.gif" width="245px" height="180px" />
<div class="rdivbanner">
<img src="/View/images/hot1.gif" style="vertical-align: middle" />热点文章</div>
<div class="rlist">
<asp:Repeater ID="RPHotInfos" runat="server">
<ItemTemplate>
<img src="/View/images/news.gif" align="middle" alt="HOT" /> <a href="/View/Aritical/<%# Eval("Iid").ToString() %>.html"
title="<%# Eval("title").ToString() %>">[<%# Eval("classify").ToString() %>] <%# Eval("title").ToString().Length<=13?Eval("title").ToString():Eval("title").ToString().Substring(0,13)+"..." %></a><br />
</ItemTemplate>
</asp:Repeater>
</div>
<div class="rdivbanner">
图片文章</div>
<div class="rlist"> <script type="text/javascript">
var focus_width=235
var focus_height=150
var text_height=20
var swf_height = focus_height+text_height
var pics=<%= pics %>;
var links=<%= links %>;
var texts=<%= texts %>;
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
document.write('<param name="allowScriptaccess" value="sameDomain"><param name="wmode" value="transparent"><param name="movie" value="/View/images/pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value=#000000>');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
document.write('<embed src="/View/images/pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor=#000000 quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
</script> </div>
<img src="/UploadFile/adimgs/gz.gif" width="245px" height="100px" style="margin: 4px 0 0 0;" />
<div class="rdivbanner">
文章评论</div>
<div class="rlist">
<asp:Repeater ID="RpComm" runat="server">
<ItemTemplate>
<div style="text-align: left; margin: 3px">
<b>By
<%# Eval("cip").ToString() %>
At
<%# Eval("ctime").ToString() %></b><hr />
<%# Eval("cdetails").ToString() %></div>
<br />
</ItemTemplate>
</asp:Repeater>
<a href="javascript:void(0)" onclick="showFloat()" style="color: Red;"><b>发表新评论</b></a>
</div>
</div>
</div> <script type="text/javascript" language="javascript">
function ShowNo() //隐藏两个层
{
document.getElementById("doing").style.display="none";
document.getElementById("divLogin").style.display="none";
}
function $(id)
{
return (document.getElementById) ? document.getElementById(id) : document.all[id] ;
}
function showFloat() //根据屏幕的大小显示两个层
{
var range = getRange();
$('doing').style.width = range.width + "px";
$('doing').style.height = range.height + "px";
$('doing').style.display = "block";
document.getElementById("divLogin").style.display="";
}
function getRange() //得到屏幕的大小
{
var top = document.body.scrollTop;
var left = document.body.scrollLeft;
var height = document.body.clientHeight;
var width = document.body.clientWidth; if (top==0 && left==0 && height==0 && width==0)
{
top = document.documentElement.scrollTop;
left = document.documentElement.scrollLeft;
height = document.documentElement.clientHeight;
width = document.documentElement.clientWidth;
}
return {top:top ,left:left ,height:height ,width:width } ;
}
</script> <!--加一个半透明层-->
<div id="doing" style="filter: alpha(opacity=30); -moz-opacity: 0.3; opacity: 0.3;
background-color: #000; width: 100%; height: 100%; z-index: 1000; position: absolute;
left: 0; top: 0; display: none; overflow: hidden;">
</div>
<!--加一个登录层-->
<div id="divLogin" style="border: solid 10px #898989; background: #fff; padding: 10px;
width: 780px; z-index: 1001; position: absolute; display: none; top: 160%; left: 50%;
margin: -200px 0 0 -400px;">
<div style="padding: 3px 15px 3px 15px; text-align: left; vertical-align: middle;">
<div>
昵称:
<asp:TextBox ID="TxtYourName" runat="server"></asp:TextBox>
</div>
<br />
<div>
主页:
<asp:TextBox ID="TxtHomePage" runat="server"></asp:TextBox>
</div>
<br />
<div>
邮箱:
<asp:TextBox ID="TxtEmail" runat="server"></asp:TextBox>
</div>
<br />
<div>
内容:
<asp:TextBox ID="TxtContent" runat="server" TextMode="MultiLine" Height="65px" Width="355px"></asp:TextBox><asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server" ErrorMessage="不能为空"
ControlToValidate="TxtContent"></asp:RequiredFieldValidator>
</div>
<br />
<div>
<asp:Button ID="BtnCommite" runat="server" Text="提交留言" OnClick="BtnCommite_Click" />
<input id="BttCancel" type="button" value="关 闭" onclick="ShowNo()" />
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
<%@ Page Language="C#" MasterPageFile="~/View/Site.Master" AutoEventWireup="true"
CodeBehind="Aritical.aspx.cs" Inherits="Web.View.WebForm1" Title="无标题页" %><asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="aritical">
<div style="width: 670px; border: solid 1px #AECBE7; background-color: #F6FCFF; float: left;
margin: 3px 0 0 3px; padding: 10px;">
<h1>
<asp:Label ID="lbTitle" runat="server" Text=""></asp:Label>
</h1>
<asp:Label ID="lbInfos" runat="server" Text=""></asp:Label>
<hr />
<div style="text-align: left; line-height: 120%;">
<asp:Label ID="lbDetails" runat="server" Text="很抱歉,您找的文章不存在或已经被删除!"></asp:Label>
</div>
</div>
<div style="width: 248px; float: right; text-align: center; margin: 3px 2px 0px 0px;">
<img src="/UploadFile/adimgs/gz.gif" width="245px" height="180px" />
<div class="rdivbanner">
<img src="/View/images/hot1.gif" style="vertical-align: middle" />热点文章</div>
<div class="rlist">
<asp:Repeater ID="RPHotInfos" runat="server">
<ItemTemplate>
<img src="/View/images/news.gif" align="middle" alt="HOT" /> <a href="/View/Aritical/<%# Eval("Iid").ToString() %>.html"
title="<%# Eval("title").ToString() %>">[<%# Eval("classify").ToString() %>] <%# Eval("title").ToString().Length<=13?Eval("title").ToString():Eval("title").ToString().Substring(0,13)+"..." %></a><br />
</ItemTemplate>
</asp:Repeater>
</div>
<div class="rdivbanner">
图片文章</div>
<div class="rlist"> <script type="text/javascript">
var focus_width=235
var focus_height=150
var text_height=20
var swf_height = focus_height+text_height
var pics=<%= pics %>;
var links=<%= links %>;
var texts=<%= texts %>;
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">');
document.write('<param name="allowScriptaccess" value="sameDomain"><param name="wmode" value="transparent"><param name="movie" value="/View/images/pixviewer.swf"><param name="quality" value="high"><param name="bgcolor" value=#000000>');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">');
document.write('<embed src="/View/images/pixviewer.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor=#000000 quality="high" width="'+ focus_width +'" height="'+ swf_height +'" allowScriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
document.write('</object>');
</script> </div>
<img src="/UploadFile/adimgs/gz.gif" width="245px" height="100px" style="margin: 4px 0 0 0;" />
<div class="rdivbanner">
文章评论</div>
<div class="rlist">
<asp:Repeater ID="RpComm" runat="server">
<ItemTemplate>
<div style="text-align: left; margin: 3px">
<b>By
<%# Eval("cip").ToString() %>
At
<%# Eval("ctime").ToString() %></b><hr />
<%# Eval("cdetails").ToString() %></div>
<br />
</ItemTemplate>
</asp:Repeater>
<a href="javascript:void(0)" onclick="showFloat()" style="color: Red;"><b>发表新评论</b></a>
</div>
</div>
</div> <script type="text/javascript" language="javascript">
function ShowNo() //隐藏两个层
{
document.getElementById("doing").style.display="none";
document.getElementById("divLogin").style.display="none";
}
function $(id)
{
return (document.getElementById) ? document.getElementById(id) : document.all[id] ;
}
function showFloat() //根据屏幕的大小显示两个层
{
var range = getRange();
$('doing').style.width = range.width + "px";
$('doing').style.height = range.height + "px";
$('doing').style.display = "block";
document.getElementById("divLogin").style.display="";
}
function getRange() //得到屏幕的大小
{
var top = document.body.scrollTop;
var left = document.body.scrollLeft;
var height = document.body.clientHeight;
var width = document.body.clientWidth; if (top==0 && left==0 && height==0 && width==0)
{
top = document.documentElement.scrollTop;
left = document.documentElement.scrollLeft;
height = document.documentElement.clientHeight;
width = document.documentElement.clientWidth;
}
return {top:top ,left:left ,height:height ,width:width } ;
}
</script> <!--加一个半透明层-->
<div id="doing" style="filter: alpha(opacity=30); -moz-opacity: 0.3; opacity: 0.3;
background-color: #000; width: 100%; height: 100%; z-index: 1000; position: absolute;
left: 0; top: 0; display: none; overflow: hidden;">
</div>
<!--加一个登录层-->
<div id="divLogin" style="border: solid 10px #898989; background: #fff; padding: 10px;
width: 780px; z-index: 1001; position: absolute; display: none; top: 160%; left: 50%;
margin: -200px 0 0 -400px;">
<div style="padding: 3px 15px 3px 15px; text-align: left; vertical-align: middle;">
<div>
昵称:
<asp:TextBox ID="TxtYourName" runat="server"></asp:TextBox>
</div>
<br />
<div>
主页:
<asp:TextBox ID="TxtHomePage" runat="server"></asp:TextBox>
</div>
<br />
<div>
邮箱:
<asp:TextBox ID="TxtEmail" runat="server"></asp:TextBox>
</div>
<br />
<div>
内容:
<asp:TextBox ID="TxtContent" runat="server" TextMode="MultiLine" Height="65px" Width="355px"></asp:TextBox><asp:RequiredFieldValidator
ID="RequiredFieldValidator1" runat="server" ErrorMessage="不能为空"
ControlToValidate="TxtContent"></asp:RequiredFieldValidator>
</div>
<br />
<div>
<asp:Button ID="BtnCommite" runat="server" Text="提交留言" OnClick="BtnCommite_Click" />
<input id="BttCancel" type="button" value="关 闭" onclick="ShowNo()" />
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
{
try
{
GetAriticalDetails();
HotInfos();
LatestImgInfos();
GetInfoComments();
UpdateHits();
}
catch
{
return;
}
}
}
//获得文章的详细信息
private void GetAriticalDetails()
{
infosController ic = new infosController();
infos info = ic.FindById_infos(int.Parse(Request["id"].ToString()));
this.lbTitle.Text = info.title;
this.lbInfos.Text = "文章类别:[" + info.classify + "] 发布人:" + info.publishman + " 发布时间:" + info.publishtime.ToString() + " 点击量:" + info.hits.ToString();
this.lbDetails.Text = info.details;
this.Title = info.title + "--起点10";
}
private void UpdateHits()
{
infosController ic = new infosController();
infos info = ic.FindById_infos(int.Parse(Request["id"].ToString()));
info.hits = info.hits + 1;
ic.Update_Infos(info);
}
private void HotInfos()
{
infosController ic = new infosController();
RPHotInfos.DataSource = ic.FindHot_infos("0", "15", "");
RPHotInfos.DataBind();
}
//绑定新闻flash图片
public string pics = "'";
public string links = "'";
public string texts = "'";
private void LatestImgInfos()
{
infosController ic = new infosController();
IList list = ic.FindByPage_infos("0", "6", "imgs!=''");
foreach (infos info in list)
{
pics += (GetFirstImg(info.imgs)) + "|";
links += "/View/Aritical/" + info.iid.ToString() + ".html|";
texts += (info.title.Length > 30 ? info.title.Substring(0, 30) + "..." : info.title) + "|";
}
pics = pics.TrimEnd('|') + "'";
links = links.TrimEnd('|') + "'";
texts = texts.TrimEnd('|') + "'";
}
private string GetFirstImg(string imgsUrl)
{
if (imgsUrl.Contains('|'))
{
string[] imgs = imgsUrl.Split('|');
return imgs[0];
}
else
return imgsUrl; }
private void GetInfoComments()
{
infocommentsController icc = new infocommentsController();
RpComm.DataSource = icc.FindAllCommentsById(Request["id"].ToString());
RpComm.DataBind();
}
protected void BtnCommite_Click(object sender, EventArgs e)
{
if (TxtContent.Text.Trim().Length <= 0)
{
MessageBox("提示", "评论信息不完整!");
}
else
{
}
}
private void MessageBox(string strKey, string strInfo)
{
if (!ClientScript.IsClientScriptBlockRegistered(strKey))
{
string strJS = "alert('" + strInfo + "');";
System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.BtnCommite, this.BtnCommite.GetType(), "ajs", strJS, true);
}
}
{
if (TxtContent.Text.Trim().Length <= 0)
{
MessageBox("提示", "评论信息不完整!");
}
else
{
this.UpdatePanel1.Update();
}
}
]<Triggers ><asp:AsyncPostBackTrigger ControlID="BtnCommite" EventName="Click" /></Triggers>后台代码:protected void BtnCommite_Click(object sender, EventArgs e)
{
if (TxtContent.Text.Trim().Length <= 0)
{
MessageBox("提示", "评论信息不完整!");
}
else
{
this.UpdatePanel1.Update();
}
}
第一次提交的地址是Aritical.aspx?id=91,第二次单击就变成Aritical/Aritical.aspx?id=91很奇怪,把所有控件都删了,只留提交,还是错误。最后定为到URLReWriter里,原来是这个错误,
我默认将Aritcal/91.html映射为Aritical.aspx?id=91改成Aritical_91.html的映射就OK了。
搞死了,
不过还是没明白为什么???