unknownsatan
unknownsatan

Reputation: 731

Working with divs in ASP.NET

Can any one tell me how can I make divs visible in ASP.NET. I tried to use a panel but it was interfering with other divs. Well, to explain my situation why I am asking is I want to show a form with submit button on a same page and thank you message after submitting it.

Any better suggestions on how can I do it? :)

Well here is code,

<%@ 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>

Upvotes: 0

Views: 5741

Answers (3)

Jupaol
Jupaol

Reputation: 21355

To make it visible to asp.net server side

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

   </div>

As an alternative to the Panel which generates a div, instead you can use the PlaceHolder control which does not generate div tags

Check this question:

Using Panel or PlaceHolder

Upvotes: 2

Idrees Khan
Idrees Khan

Reputation: 7752

You can use asp:Literal like this;

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

And then when a form is submitted change the visbility of this literal like this;

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

this is the simples way and the benefit is that you dont get anything inside the div tag, infact you get just text.

Upvotes: 0

Ufuk Hacıoğulları
Ufuk Hacıoğulları

Reputation: 38468

You can use runat="server" attribute on that div and set its Visible property on the server side.

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

</div>

You can decide if page should render it in PageLoad or other events.

someDiv.Visible = someCondition;

Upvotes: 2

Related Questions