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

  • Thread starter Thread starter Guest
  • Start date Start date
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,
 
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
 
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
 
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,
 
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

Back
Top