473,761 Members | 2,285 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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"t o 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">E mployee 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'b ut
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 6882
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.C ontrol. The Visible
property belongs to .Net controls, which DIV is not. unfortunately just
adding on a "runat=serv er" 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.getEle mentById('txtBo xwhatever').

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 misunderstandin g 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**********@f tsolutions.comw rote in message
news:O1******** ******@TK2MSFTN GP05.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">E mployee 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'b ut
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********@com munity.nospamwr ote in message
news:OB******** ******@TK2MSFTN GP02.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.C ontrol. The
Visible property belongs to .Net controls, which DIV is not.
unfortunately just adding on a "runat=serv er" 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 programmaticall y 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.getEle mentById('txtBo xwhatever').
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 misunderstandin g 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**********@f tsolutions.comw rote in message
news:O1******** ******@TK2MSFTN GP05.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">E mployee 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.Form s.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=serverbec ause 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><tabl e 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********@com munity.nospamwr ote in message
news:Od******** ******@TK2MSFTN GP04.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=serverbec ause 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><tabl e 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">E mployee 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;fon t-weight:bold;hei ght:24px;">Empl oyee
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
2203
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 functioning. Same way when we place a UserControl on one of the panel. Also, when the user is in a textbox below the Button on the same panel,
1
1297
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 "Object reference not set to an instace of an object". It does not appear if I do a regular build. How can I identify where this problem is happening? When I double click on the error it just takes me to the top of the source code for the panel but...
1
1702
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 public properties of a custom Control neatly tied together -- rather than all over the IDE. One such set of values that will rarely be changed, so should have little priority in the IDE Properties panel, and therefore a good candidate for
1
3598
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 I am hoping someone knows what I am doing wrong: 1) Pressing the Settings.. Button multiple times, brings up many instances of the Settings Panel. I just want it to bring up one. Is there an easy way to do that?
1
12086
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" docked to fill the remaining client area of the
0
965
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 within a panel. This seemed to work, though I had limited success with the scrollbars which I was trying to maintain myself. Since I was not happy with the scrollbars I decided to let windows handle that by creating a drawing panel within my map panel...
1
2670
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 bottom. I want the top and bottom buttons to be of comparable size to the buttons in the centre row. However, each row of the gridlayout is the same size so, as a result, the top and bottom buttons are huge and the central ones are squeezed. I don't know...
1
1405
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 this panel is set to maximize. I got it to where the panel maximizes with the form but the controls (labels, radio buttoons, datagrid, etc) on the panel dont scale. Is there a way i can scale all the controls in that form. I tried the scale...
2
2610
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 the GUI for the Connect Four game */ import javax.swing.*; import javax.swing.border.*;
0
9353
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10123
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9975
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9788
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8794
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7342
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3481
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2765
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.