0

ASP.NET で div を表示する方法を教えてください。パネルを使用しようとしましたが、他の 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を生成するの代わりに、タグを生成しないコントロールをdiv使用できます。PlaceHolderdiv

この質問を確認してください:

パネルまたはプレースホルダーの使用

于 2012-06-17T21:48:56.297 に答える
2

その div で属性を使用runat="server"し、サーバー側でその 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 に答える