Div section does not dispaly

T

Ted Ngo

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{

txtSource.Focus();
frmMain.Visible = true;
divWait.Visible = false;
btnsubmit.Visible = true;

}
else
{
frmMain.Visible = false;
divWait.Visible = true;
btnsubmit.Visible = false;
LoadData();
}

}

private void LoadData()
{
//Do something

//Aftere do something
divWait.Visible = true;
}

<body bgColor=#ffffff leftMargin=0 topMargin=0 rightMargin=0
bottomMargin=0>
<form id="frmMain" Visible="False" runat="server">
<table id=tbl1 runat=server border=0 width=100%>
<tr>
<td width=20% class=lbltxt>
<asp:Label ID=Label1 Text="testone:"
runat=server></asp:Label>
</td>
<td class=lbltxt>
<asp:TextBox ID=txtSource Width=250px
runat=server></asp:TextBox>
</td>

</tr>


<tr>
<td colspan=2 class=lbltxt>
<asp:Button ID=btnsubmit runat=server
Text="Submit"/>
</td>
</tr>

</table>
</form>

<div id="divWait" style="display:none; font-weight: bold;
font-size: 12pt; color: navy; font-family: Verdana; background-color:
#ffff99;"
Visible="False" runat="server">
<center>
<span id="Span1">Please, wait ... </span>
</center>
</div>

</body>
</html>

When I click on the submit button, it go to the posk back, but it did
not hide the my Form, my submit button, and also it does not turn on
the div "DivWait". I show up on after the LoadData function finish.
Why?

I did try
mtaRefresh.Attributes.Add("http-equiv", "refresh")
mtaRefresh.Attributes.Add("content", "0;url=" & sRefreshURL)
but it still does not work;

Basicly I want to dispaly the wait message, when I data is loading at
all, and turn it off ater I done loading.

Please help.
 
M

Marina Levit [MVP]

The Visible property does not refer to the 'display' property of the 'style'
that you are setting.

Visible controls whether or not the HTML for the element is generated at
all. When it is false, that div won't even exist in the HTML on the client.
When it is visible, that HTML will be sent down.

However, you are setting the visibility on the client side by setting
"display: none", so it's not visible. You should stick to either toggling
the server side Visibility property of your div (which can change whether
HTML is generated for it), or you can do it on the client (in which case the
div will alway be there, but you can on the client control whether or not it
is visible).
 
T

Ted Ngo

Hi

I also try this, but it still does not show: my P2 does not show up at
all.

<script>
function Validate()
{
document.getElementById("P2").style.visibility = "visible";
document.getElementById("btnsubmit").style.visibility =
"hidden";
document.getElementById("btnsubmit").style.display =
"none";

}

</script>

<form id="frmMain" runat="server">


</asp:panel>

<asp:panel ID=P2 runat=server visiable=false
<table id="Table1" runat=server>

<tr>
<td>
Please Wait ...1
</td>
</tr>
</table>
</asp:panel>



</asp:panel>

<asp:Button ID=btnsubmit runat=server

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{

}
else
{
CreateFile();
}

this.btnsubmit.Attributes.Add("onclick", "Validate()");


}
 
G

George Ter-Saakov

There is no such thing as
style.visibility = "visible";

Use
document.getElementById("P2").style.display = "inline";

George
 
D

Dave Sexton

Hi Ted,

I believe that Marina already answered this for you.

You told the browser to make P2 visible by using JavaScript:

document.getElementById("P2").style.visibility = "visible";

But the browser is never even receiving the P2 html because of the Visible attribute in the server declaration:

<asp:panel ID=P2 runat=server visiable=false

(which, BTW, is invalid html and won't compile. visiable should be visible, and you forgot the closing ">")

As Marina stated, you can have it only one way or the other. Either visibility is controlled via the Visible=false attribute in the
server tag, in which case the browser will never receive the P2 markup, or you can leave Visible=true on the server tag and use CSS
on the client-side to control visibility via the style's "visibility" or "display" attributes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top