0

谁能告诉我如何让 div 在 ASP.NET 中可见。我尝试使用面板,但它干扰了其他 div。好吧,为了解释我的情况,我为什么要在同一页面上显示一个带有提交按钮的表单,并在提交后感谢您的消息。

关于我该如何做的任何更好的建议?:)

那么这里是代码,

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script type="text/javascript">
    function Show(moreInfo) {
        document.getElementById(btnInfo).style.visibility='hidden';
        document.getElementById(moreInfo).style.visible = 'visible';
    </script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .heading
        {
            text-align: center;
            border-style: double;
            background-color:#F2A988;
            font-family:Sans-Serif;
            font-weight:bold;

        }
        #wrapper {
            margin: 0 auto;
            width: 400px; 
            text-align:left;
        }
        .style1
        {
            text-align: center;
            font-family:Sans-Serif;
        }
    </style>
</head>
<body style="height: 642px; width: 911px; " id="wrapper">
    <form id="form1" runat="server">

    <div class="heading">
        Sheridan Computer Club - Inquiry Form</div>
        <br />

    <asp:Calendar ID="Calendar1" runat="server" Font-Names="Arial"></asp:Calendar>



        <br />

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <asp:Button ID="btnInfo" runat="server" Font-Names="Arial" 
         style="font-weight: 700" 
        Text="I'd like to receive more information!" Width="261px" />

    <div style="position:relative; top: 0px; left: 0px; width: 463px; height: 188px;">
        Show the div</div>

    <div id="meeting" 




        style="position:relative; top: -285px; left: 320px; width: 232px; height: 64px; text-align: center; margin-top: 0px; font-family: Arial; font-weight:bold;">
        <br />
&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:Label ID="lblDate" runat="server"></asp:Label>
        <br />
        </div>



    <div style="width: 308px; position:relative; top: -479px; left: 283px; margin-top: 0px;" 
        class="style1">
        Click Below to find out when
        <br />
        the club meets next</div>

    <div style="position:relative; top: -515px; left: 624px; width: 274px; height: 289px; font-family:Sans-Serif;">
        <b>View Members by Program:<br />
        <asp:ListBox ID="ListBox1" runat="server" Height="175px" Width="263px">
        </asp:ListBox>
        </b></div>

    <div style="position:relative; top: -739px; left: 346px; width: 192px; height: 32px; text-align: center; margin-top: 0px;">
        <asp:Button ID="Button1" runat="server" Text="Next Meeting" 
            onclick="Button1_Click" />
    </div>

    </form>
</body>
</html>
4

3 回答 3

2

使其对 asp.net 服务器端可见

   <div runat="server" id="mydiv">

   </div>

作为Panel生成 a的替代方法div,您可以使用PlaceHolder不生成div标签的控件

检查这个问题:

使用面板或占位符

于 2012-06-17T21:48:56.297 回答
2

您可以runat="server"在该 div 上使用属性并在服务器端设置其 Visible 属性。

<div runat="server" ID="someDiv" >

</div>

您可以决定页面是否应该在 PageLoad 或其他事件中呈现它。

someDiv.Visible = someCondition;
于 2012-06-17T21:52:19.587 回答
0

你可以像这样使用 asp:Literal;

<div>
      <asp:Literal runat="server" ID="litHide" Visible="false" />
</div>

然后当提交一个表单时,像这样改变这个文字的可见性;

if(litHide.visible==false)
{
 litHide.visible = true;
}

这是最简单的方法,好处是你不会在 div 标签中得到任何东西,事实上你得到的只是文本。

于 2012-06-17T21:52:51.827 回答