473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problems with div and Panel with VS

I am trying to hide and show certain parts of my code (which I have no
problem doing with DW). In VS 2003, it won't let you use <div
runat="server"to section of parts of my code in a table. This is during
compilation (build).

My code is:

<TABLE id="Table1" style="WIDTH: 864px; HEIGHT: 177px" cellSpacing="1"
cellPadding="1"
width="864" border="0">
<div ID="LogonPanel" Runat="server">
<TR>
<TD colSpan="3">
<asp:label id="Label1" runat="server" Height="24px" Font-Bold="True"
Font-Size="Larger">Employee Login</asp:label></TD>
</TR>
....
</div>
</Table>

The errors I get are:
1. Could not find any attribute 'Visible' of element 'div'.
2. Per the active schema, the element 'div' cannot be nested within 'table'.

If I change the <divto <asp:Panel>, I can't access the Textbox.Text?

It worked fine until I used the Panel. I just put the Panel around the
Logon section and my code wants to access the Textbox that has the user name
in it:

The problem seems to be that when the Panel is not visible anything inside
is not rendered. This is not the case when using <div runat='server'but
VS won't let me use that.

Or is there something I need to do to tell VS to handle it?

Thanks,

Tom
'Document.Forms.0.TextBox1' is null or not an object.
Sep 21 '06 #1
4 6849
hi,
the problem isn't with VS 2003. the DIV HTML element has no property called
Visible because it doesn't inherit from System.Web.UI.Control. The Visible
property belongs to .Net controls, which DIV is not. unfortunately just
adding on a "runat=server" does not make the control a .Net control. it
just gives you server side access to a HTML element.

it sounds like you might make better use of PlaceHolders which leave no
markup on the page, and can be used for Showing/Hiding other controls or
HTML. also the VS designer will probably complain if you put server
controls in invalid places, such as between TABLE and TR tags. it may
refuse to draw the page and throw you into HTML mode.

also, you can't nest a DIV directly inside a TABLE tag because it is invalid
HTML by any standard.

the javascript you're using also appears to be nonstandard. I would
recommend document.getElementById('txtBoxwhatever').

when a Panel is not visible, none of its contents are rendered. This is the
point of setting Visible=False, i.e. the user shouldn't be able to see it,
and by inference the HTML shouldn't be rendered.

do you want to use client-side show/hide functionality? it sounds like your
DW background is making life difficult. if you hide a control on the
server, then the rendered HTML is not included for that control. if you
hide it on the client, the HTML never changes and the browser simply makes
the element invisible. i'm sure you know that already but it sounds like
there is some misunderstanding between the effects of server-side and
client-side code.

i hope this answers your question, let me know if anything i've written
isn't clear.
tim.
"tshad" <ts**********@ftsolutions.comwrote in message
news:O1**************@TK2MSFTNGP05.phx.gbl...
>I am trying to hide and show certain parts of my code (which I have no
problem doing with DW). In VS 2003, it won't let you use <div
runat="server"to section of parts of my code in a table. This is during
compilation (build).

My code is:

<TABLE id="Table1" style="WIDTH: 864px; HEIGHT: 177px" cellSpacing="1"
cellPadding="1"
width="864" border="0">
<div ID="LogonPanel" Runat="server">
<TR>
<TD colSpan="3">
<asp:label id="Label1" runat="server" Height="24px" Font-Bold="True"
Font-Size="Larger">Employee Login</asp:label></TD>
</TR>
...
</div>
</Table>

The errors I get are:
1. Could not find any attribute 'Visible' of element 'div'.
2. Per the active schema, the element 'div' cannot be nested within
'table'.

If I change the <divto <asp:Panel>, I can't access the Textbox.Text?

It worked fine until I used the Panel. I just put the Panel around the
Logon section and my code wants to access the Textbox that has the user
name in it:

The problem seems to be that when the Panel is not visible anything inside
is not rendered. This is not the case when using <div runat='server'but
VS won't let me use that.

Or is there something I need to do to tell VS to handle it?

Thanks,

Tom
'Document.Forms.0.TextBox1' is null or not an object.

Sep 21 '06 #2

"Tim_Mac" <ti********@community.nospamwrote in message
news:OB**************@TK2MSFTNGP02.phx.gbl...
hi,
the problem isn't with VS 2003. the DIV HTML element has no property
called Visible because it doesn't inherit from System.Web.UI.Control. The
Visible property belongs to .Net controls, which DIV is not.
unfortunately just adding on a "runat=server" does not make the control a
.Net control. it just gives you server side access to a HTML element.
Actually, DIV with runat="Server" (which allows the visibility property)
works great. Even DW complains about it not being standard. But I had
found out about this a couple of years ago and have been using it since. It
works great. Not sure why. But obviously it obviously is handled correctly
by the server side.

For example:

Before Div
<div ID="test" Visible="true" runat='server'>This is a test</div>
After Div

will render as:
Before Div
<div id="test">This is a test</div>
After Div

and

Before Div
<div ID="test" Visible="false" runat='server'>This is a test</div>
After Div

renders as:

Before Div

After Div

This allows you to control your text and controls programmatically like
using an asp:Panel. There was something different about the Panel and Div -
but I can't remember what it was.

These links also talk about it.
http://www.thescripts.com/forum/thread532743.html
http://msdn.microsoft.com/msdnmag/is...5/CuttingEdge/
http://cfouquet.blogspot.com/
>
it sounds like you might make better use of PlaceHolders which leave no
markup on the page, and can be used for Showing/Hiding other controls or
HTML. also the VS designer will probably complain if you put server
controls in invalid places, such as between TABLE and TR tags. it may
refuse to draw the page and throw you into HTML mode.
Actually, Div leaves no markup if visible=false. It renders exactly the
same (so not sure why we have Div for this if Panel does the job). Here is
the result if I change the above Div to asp:Panel.

Before Div
<div id="test">
This is a test
</div>
After Div

Exactly the same.
also, you can't nest a DIV directly inside a TABLE tag because it is
invalid HTML by any standard.
If this is the right, then I don't believe you would be able to use Panel
inside you repeaters and datagrids as they just translate into tables.

I use Div's inside tables all the time.
the javascript you're using also appears to be nonstandard. I would
recommend document.getElementById('txtBoxwhatever').
What Javascript? From another post?
>
when a Panel is not visible, none of its contents are rendered. This is
the point of setting Visible=False, i.e. the user shouldn't be able to see
it, and by inference the HTML shouldn't be rendered.
Same as Div.

I was mistaken about being able to access a textbox when visible=false for
Div. I thought I was able to access it.
do you want to use client-side show/hide functionality? it sounds like
your DW background is making life difficult. if you hide a control on the
server, then the rendered HTML is not included for that control. if you
hide it on the client, the HTML never changes and the browser simply makes
the element invisible. i'm sure you know that already but it sounds like
there is some misunderstanding between the effects of server-side and
client-side code.
No. I didn't want client side functionality. I use Div to show/hide areas
of my screen depending on what the client has entered or what I get back
from a database.

My problem is the VS is preventing me from doing what I have been doing for
years and apparently is valid. I was curious if there was a way to get VS
to allow this. I have pages I am trying to move to my VS project that use
this technique and I don't want to have to recode these pages.

Thanks,

Tom
>
i hope this answers your question, let me know if anything i've written
isn't clear.
tim.
"tshad" <ts**********@ftsolutions.comwrote in message
news:O1**************@TK2MSFTNGP05.phx.gbl...
>>I am trying to hide and show certain parts of my code (which I have no
problem doing with DW). In VS 2003, it won't let you use <div
runat="server"to section of parts of my code in a table. This is during
compilation (build).

My code is:

<TABLE id="Table1" style="WIDTH: 864px; HEIGHT: 177px" cellSpacing="1"
cellPadding="1"
width="864" border="0">
<div ID="LogonPanel" Runat="server">
<TR>
<TD colSpan="3">
<asp:label id="Label1" runat="server" Height="24px" Font-Bold="True"
Font-Size="Larger">Employee Login</asp:label></TD>
</TR>
...
</div>
</Table>

The errors I get are:
1. Could not find any attribute 'Visible' of element 'div'.
2. Per the active schema, the element 'div' cannot be nested within
'table'.

If I change the <divto <asp:Panel>, I can't access the Textbox.Text?

It worked fine until I used the Panel. I just put the Panel around the
Logon section and my code wants to access the Textbox that has the user
name in it:

The problem seems to be that when the Panel is not visible anything
inside is not rendered. This is not the case when using <div
runat='server'but VS won't let me use that.

Or is there something I need to do to tell VS to handle it?

Thanks,

Tom
'Document.Forms.0.TextBox1' is null or not an object.


Sep 21 '06 #3
hi tom,
yes i see now that the HtmlControls also have a Visible server side
property.

based on your original post, you had problems with an invisible control not
rendering any HTML. from what you've just written you seem to understand
this already so i'm not sure what the problem was. VS only complained about
the <div runat=serverbecause you had it in between a TABLE and TR tag.

you can of course use Panels inside DataGrids and Repeaters. the problem
was that you had nested the tags in an incorect order. the browser will
still render it and you'll probably get funny gaps in the table, but you
can't expect consistent results with this kind of invalid markup:
<table><div><tr><td>

if you put a Panel inside a DataGrid, you'll get something like this:
<Table id='DataGrid1'><tr><td><table id='Panel1'>... this is Valid markup.

your post included a javascript error on the last line.

you can use server-divs, PlaceHolders, or Panels, all to achieve the same
effect. VS does not have a problem with any. my point about PlaceHolders
was simply that they do not leave a DIV or TABLE tag behind when they render
(Visible). obviously an invisible control will not render any HTML.

tim
Sep 22 '06 #4
"Tim_Mac" <ti********@community.nospamwrote in message
news:Od**************@TK2MSFTNGP04.phx.gbl...
hi tom,
yes i see now that the HtmlControls also have a Visible server side
property.

based on your original post, you had problems with an invisible control
not rendering any HTML. from what you've just written you seem to
understand this already so i'm not sure what the problem was. VS only
complained about the <div runat=serverbecause you had it in between a
TABLE and TR tag.
The problem was that I had 2 errors that it wouldn't build from - I am
trying to find out if there is a setting that will allow me to do it.

1. Could not find any attribute 'Visible' of element 'div'.
2. Per the active schema, the element 'div' cannot be nested within 'table'.

As you saw, there is a Visible attribute - if you also have runat=visible.
As you said, it will not render anything if set to false. So they should
allow it. It is valid.

The other error seems to be fine (at least for IE) so this should be allowed
also. Especially since they render Panel to Div inside of a table for IE.
>
you can of course use Panels inside DataGrids and Repeaters. the problem
was that you had nested the tags in an incorect order. the browser will
still render it and you'll probably get funny gaps in the table, but you
can't expect consistent results with this kind of invalid markup:
<table><div><tr><td>

if you put a Panel inside a DataGrid, you'll get something like this:
<Table id='DataGrid1'><tr><td><table id='Panel1'>... this is Valid markup.
Actually, this is not the case in IE (it is in Mozilla and Firefox,
however).

I have the following code:

<TABLE id="Table1" style="WIDTH: 864px; HEIGHT: 177px" cellSpacing="1"
cellPadding="1"
width="864" border="0">
<asp:panel id="LogonPanel" Runat="server">
<TR>
<TD colSpan="3">
<asp:label id="Label1" runat="server" Height="24px" Font-Bold="True"
Font-Size="Larger">Employee Login</asp:label></TD>
</TR>
....

and the viewsource shows:

<TABLE id="Table1" style="WIDTH: 864px; HEIGHT: 177px" cellSpacing="1"
cellPadding="1"
width="864" border="0">
<div id="LogonPanel">
<TR>
<TD colSpan="3">
<span id="Label1"
style="font-size:Larger;font-weight:bold;height:24px;">Employee
Login</span></TD>
</TR>

My problem is that VS should allow this if you want it - they obviously do
it.
your post included a javascript error on the last line.

you can use server-divs, PlaceHolders, or Panels, all to achieve the same
effect. VS does not have a problem with any. my point about PlaceHolders
was simply that they do not leave a DIV or TABLE tag behind when they
render (Visible). obviously an invisible control will not render any
HTML.
You right I can do all these but they're messages are not correct (Visible
is valid).

The other thing that was driving me crazy was the stupid <TBODYthat kept
showing up and messing up my code. I actually had 2 Panel sections back to
back. When one if visible the other isn't. It kept putting the <TBODY>
inside the first <asp:Paneltag and the closing tag </TBODYinside the 2nd
</asp:Panel>. I kept getting an error saying the <TBODYtags were nested
incorrectly (the problem was they did it). I kept having to delete these to
make my code work. Not sure what was causing it but when I made certain
changes - it kept showing up. Must have done this about 10 times.

Thanks,

Tom
>
tim

Sep 22 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: raosundar | last post by:
Hi, I have two panels on a C# WinForm contains set of buttons with shortcut (eg. Alt+K) on each Panel. Now when the user is on one panel, the shortcuts of other panel buttons are not...
1
by: steve bull | last post by:
I have encountered the following problems when creating new controls that I have added to the toolbox : 1. When I click on the design panel containing a number of widgets I get a build error of...
1
by: Sky Sigal | last post by:
(PS: Cross post from microsoft.pulic.dotnet.framework.aspnet.webcontrols) I've been looking lately for a way to keep the Properties panel for Controls 'clean'... My goal is to keep similar...
1
by: Michael Yanowitz | last post by:
Hello: Below I have included a stripped down version of the GUI I am working on. It contains 2 dialog boxes - one main and one settings. It has the following problems, probably all related, that...
1
by: TheSteph | last post by:
Hi ! I would like to create a UserControl that act as a « Collapsible Panel ». So I have a UserControl with two panels : a "Header panel" at the top, and a "Container Area Panel"...
0
by: Tyreec | last post by:
Hi, I am hoping that someone can give me some pointers on where I am going wrong. First some background. I wanted to create a windows application that would draw a map that could be scaled...
1
by: Didje | last post by:
Hi, I am trying to create a grid which contains three rows, within each row there will be various buttons also in gridlayout. There are 20 buttons in the middle row, 3 in the top and 4 at the...
1
by: jojo11368 | last post by:
Hello Iam using visual studio 2005. I want to extend/scale a panel and the controls in the panel on a form. Currently i have a default size for the panel. The forms windowstate containing...
2
by: vertozia | last post by:
Hey there, ive been having difficulty placing an image, this is my screenshot, and what ive done so far: http://img341.imageshack.us/img341/9894/gridwg2.jpg /** * ConnectFourGUI * Provide...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.