<div id="help" runat="server"></div>


J

Jim in Arizona

Most of the asp.net learning I've done has been from books that were written
during the 1.0 framework. I didn't have a copy of visual studio when I
started reading them then I got a hold of VS 2005 Beta 1, then Beta 2.

I was using the <div runat="server"> statement on my projects. Once I placed
a <div id="testdiv" runat="server"> within my aspx page, I could then
manipulate it in the code behind like so:

testdiv.visible = true
testdiv.innerhtml = mystring

I recently got a copy of VS 2003 developer and started to recode a project
of mine that I did under the 2.0 beta2 framework. I have been coming along
ok except for the <div> statement. For some reason, in the code behind, VS
does not recognize <div>. the testdiv portion of testdiv.visible = true is
underlined and says that it isn't declared.

Why would framework 1.0 and 2.0 (Visual studio) understand what it is but
the 1.1 not? If I can no longer use testdiv.innerhtml = mystring to produce
html output streams, then what do I do instead to output data tables in a
format that I want them to look instead of a simple grid?

TIA,
Jim
 
Ad

Advertisements

K

Karl Seguin

The page framework has changed in 2.0. With Partial Classes, the codebehind
and the aspx file are the same class. So your testdiv which is declared in
the aspx file is readily visible in your codebehind.

in 1.1 the aspx file inherited from the codebehind. If you declare and
instantiate a control in your aspx, it must be separately declared in your
codebehind file as well.

All that to say, put:
Protected testdiv as HtmlGenericControl in your codebehind's class

public class MyPage
inherits Page

Protected testdiv as HtmlGenericControl //the name here matches the Id
of the control

sub Page_load(..)
testvid.whatever = whatever

Karl
 
J

Jim in Arizona

Karl Seguin said:
The page framework has changed in 2.0. With Partial Classes, the
codebehind and the aspx file are the same class. So your testdiv which is
declared in the aspx file is readily visible in your codebehind.

in 1.1 the aspx file inherited from the codebehind. If you declare and
instantiate a control in your aspx, it must be separately declared in your
codebehind file as well.

All that to say, put:
Protected testdiv as HtmlGenericControl in your codebehind's class

public class MyPage
inherits Page

Protected testdiv as HtmlGenericControl //the name here matches the Id
of the control

sub Page_load(..)
testvid.whatever = whatever

Karl


Thanks Karl. I will certainly give that a try. If I find myself producing
more gray hair than normal, I'll get back to you! ;o)
 
Ad

Advertisements

K

Kevin Spencer

Hi Jim,

It all depends on the coding model you're using. If you are coding in .Net
1.1 and using the CodeBehind model, the Page Template inherits the
CodeBehind. Therefore, you need to declare the div as an HtmlGenericControl
in the CodeBehind class, and give it Protected access, so that it defines
the div in the inherited Page class. If you use the Code-in-Page model, you
don't have to do this.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition
 

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