Me.Controls(0) vs. Me.Controls(1)

G

Guest

Hello All:

Does anyone know what Me.Controls(0) refers to? I know that Me.Controls(1)
refers to the form. Is Me.Controls(0) the Page?

TIA,
 
K

Karl Seguin

You could add a breakpoint in Page_Load and add a watch on the object.

It's a literal control. It contains (typically) everything from the top of
the page to the <body> tag. Here's a sample:

\r\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"
\r\n<HTML>\r\n <HEAD>\r\n <title>index</title>\r\n </HEAD>\r\n
<body>\r\n

ASP.Net parses pure HTML elements (ie, non-ASP.Net elements) into
LiteralControls. This is why you shouldn't reference things ordinally.

Karl
 
G

Guest

Hi Karl,

I reied to do some poking about in the Command- Immediate window and wasn't
able to find anything out. This helps.

I agree; I would not usually use ordinals but don't know what else s
available in this case. What else would you suggest for me to get a refernce
to the "Form control" other than Me.Controls(1) since controls only takes an
integer as it's argument?

Thanks,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation


Karl Seguin said:
You could add a breakpoint in Page_Load and add a watch on the object.

It's a literal control. It contains (typically) everything from the top of
the page to the <body> tag. Here's a sample:

\r\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"
\r\n<HTML>\r\n <HEAD>\r\n <title>index</title>\r\n </HEAD>\r\n
<body>\r\n

ASP.Net parses pure HTML elements (ie, non-ASP.Net elements) into
LiteralControls. This is why you shouldn't reference things ordinally.

Karl
 
K

Karl Seguin

Well, you can give the form an id and use:

dim form as HtmlForm = ctype(Page.FindControl("Form1"), HtmlForm)

or, the most logical, you can simply declare your form as you would other
controls

public class MyPage
Inherits Page
protected form1 as HtmlForm

sub Page_Load
form1.XX
end sub
end class

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/

Joe said:
Hi Karl,

I reied to do some poking about in the Command- Immediate window and
wasn't
able to find anything out. This helps.

I agree; I would not usually use ordinals but don't know what else s
available in this case. What else would you suggest for me to get a
refernce
to the "Form control" other than Me.Controls(1) since controls only takes
an
integer as it's argument?

Thanks,
 
B

Bruce Barker

the Me.Controls is the collection of controls to be rendered on the page.
Control[0] will be markup before the first server control (which is
converted to a literal control), Control[1] will be the first server control
on the page, often but not always the form.

-- bruce (sqlwork.com)
 

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top