<%@ Page Language="C#" AutoEventWireup="true" CodeFile="添加好友.aspx.cs" Inherits="添加好友" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>    <script type="text/javascript">
var t_DiglogX,t_DiglogY,t_DiglogW,t_DiglogH;function gid(id) {
return document.getElementById?document.getElementById(id):null;
}function gname(name) {
return document.getElementsByTagName?document.getElementsByTagName(name):new Array()
}function Browser() {
var ua, s, i;
this.isIE = false;
this.isNS = false;
this.isOP = false;
this.isSF = false;
ua = navigator.userAgent.toLowerCase();
s = "opera";
if ((i = ua.indexOf(s)) >= 0) {
this.isOP = true;return;
}
s = "msie";
if ((i = ua.indexOf(s)) >= 0) {
this.isIE = true;return;
}
s = "netscape6/";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;return;
}
s = "gecko";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;return;
}
s = "safari";
if ((i = ua.indexOf(s)) >= 0) {
this.isSF = true;return;
}
}function DialogLoc() {
var dde = document.documentElement;
if (window.innerWidth) {
var ww = window.innerWidth;
var wh = window.innerHeight;
var bgX = window.pageXOffset;
var bgY = window.pageYOffset;
} else {
var ww = dde.offsetWidth;
var wh = dde.offsetHeight;
var bgX = dde.scrollLeft;
var bgY = dde.scrollTop;
}
t_DiglogX = (bgX + ((ww - t_DiglogW)/2));
t_DiglogY = (bgY + ((wh - t_DiglogH)/2));
}function DialogShow(showdata,ow,oh,w,h) {
var objDialog = document.getElementById("DialogMove");
if (!objDialog) objDialog = document.createElement("div");
t_DiglogW = ow;
t_DiglogH = oh;
DialogLoc();
objDialog.id = "DialogMove";
var oS = objDialog.style;
oS.display = "block";
oS.top = t_DiglogY + "px";
oS.left = t_DiglogX + "px";
oS.margin = "0px";
oS.padding = "0px";
oS.width = w + "px";
oS.height = h + "px";
oS.position = "absolute";
oS.zIndex = "5";
oS.background = "#FFF";
oS.border = "solid #C474BD 3px";
objDialog.innerHTML = showdata;
document.body.appendChild(objDialog);
}function DialogHide() {
ScreenClean();
var objDialog = document.getElementById("DialogMove");
if (objDialog) objDialog.style.display = "none";
}function ScreenConvert() {
var browser = new Browser();
var objScreen = gid("ScreenOver");
if (!objScreen) var objScreen = document.createElement("div");
var oS = objScreen.style;
objScreen.id = "ScreenOver";
oS.display = "block";
oS.top = oS.left = oS.margin = oS.padding = "0px";
if (document.body.clientHeight)    {
var wh = document.body.clientHeight + "px";
} else if (window.innerHeight) {
var wh = window.innerHeight + "px";
} else {
var wh = "100%";
}
oS.width = "100%";
oS.height = wh;
oS.position = "absolute";
oS.zIndex = "3";
if ((!browser.isSF) && (!browser.isOP)) {
oS.background = "#181818";
} else {
oS.background = "#F0F0F0";
}
oS.filter = "alpha(opacity=40)";
oS.opacity = 40/100;
oS.MozOpacity = 40/100;
document.body.appendChild(objScreen);
var allselect = gname("select");
for (var i=0; i<allselect.length; i++) allselect.style.visibility = "hidden";
}function ScreenClean() {
var objScreen = document.getElementById("ScreenOver");
if (objScreen) objScreen.style.display = "none";
var allselect = gname("select");
for (var i=0; i<allselect.length; i++) allselect.style.visibility = "visible";
}//举报
function Report(Type,ID)
{
   var PostData = "do=" + Type + "&reportid=" + ID;
   //PostRequest(window.location.protocol + "//" + window.location.host + "/AJAX_Comm.aspx", PostData);
   var showData = sample.innerHTML;
   //ScreenConvert();DialogShow("<div id=\"DialogLoading\">正在读取,请稍候...</div>",110,10,124,20);
   ScreenConvert();DialogShow(showData,400,300,288,189);}    </script></head>
<body>
    <div class="VoteAction">
        <a class="BL" onclick="this.blur();Report('reportvote',1175222);return false;" href="http://www.3http.com#">
            加为好友</a></div>
    <form runat="server" id="form1">
        <pre id="sample" style="display: none">
            <div id="DialogTitle">
                <div id="DialogTitleText" align="Center">
                    <br />
                    <img src="images/lv.gif" alt="" />
                    <strong><font color="#C474BD">需要通过王善军的验证才能加他为好友!</font> </strong>
                    <br />
                    <br />
                </div>
                <div id="DialogContent" align="Center">
                    <asp:TextBox runat="server" ID="txtContext" TextMode="MultiLine" Height="75px"></asp:TextBox>
                    <div id="DialogValidator">
                    </div>
                    <div id="DialogButtons">
                        <br />
                        <asp:Button runat="server" ID="btnFriend" Text="提交" Font-Bold="true" OnClick="btnFriend_Click"
                            ForeColor="#C474BD" />
                        <asp:Button runat="server" ID="btnReset" Text="取消" OnClientClick="return DialogHide();"
                            Font-Bold="True" ForeColor="#C474BD" />
                    </div>
                </div>
            </div>
        </pre>
    </form> 
</body>
</html>

解决方案 »

  1.   

    [color=#FF0000]上面是代码层,这个层实现的是点加为好友链接,弹出一个发送信息的层.该层主要是获得文本框的值,并将值传到数据库.但问题是我的提交按钮无响应.已排除错误页面加载时未加if (!IsPostBack). 大哥大姐帮忙看看啊!!![color]
      

  2.   

    用这段代码 <asp:Button runat="server" ID="btnFriend" Text="提交" Font-Bold="true" OnClientClick="javascript:form1.submit()"
                          
      

  3.   

    或者楼主,
    把代码换成下面就行了1.<form runat="server" id="form1">
      2.      <pre id="sample" style="display: none"> 
    交换位置 <pre id="sample"    style="display:none;" >
        <form id="form1" runat="server">
            
                <div id="DialogTitle">
                    <div id="DialogTitleText" align="Center">
                        <br />
                        <img src="images/lv.gif" alt="" />
                        <strong><font color="#C474BD">需要通过王善军的验证才能加他为好友! </font></strong>
                        <br />
                        <br />
                    </div>
                    <div id="DialogContent" align="Center">
                        <asp:TextBox runat="server" ID="txtContext" TextMode="MultiLine" Height="75px"> </asp:TextBox>
                        <div id="DialogValidator">
                        </div>
                        <div id="DialogButtons">
                            <br />
                            <asp:Button runat="server" ID="btnFriend" Text="提交" Font-Bold="true"
                                ForeColor="#C474BD" OnClick="btnFriend_Click1" />
                            <asp:Button runat="server" ID="btnReset" Text="取消" OnClientClick="return DialogHide();"
                                Font-Bold="True" ForeColor="#C474BD" />
                        </div>
                    </div>
                </div>
          
        </form>  </pre>