Thursday, March 22, 2012

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

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,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA AutomationYou 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

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

"Joe" <joeherro@.donotspam.yahoo.com> wrote in message
news:A8C6DC3A-E46D-4918-B38B-3B6FFE4FE4CA@.microsoft.com...
> 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,
> --
> Joe
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
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" wrote:

> 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
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
> news:A8C6DC3A-E46D-4918-B38B-3B6FFE4FE4CA@.microsoft.com...
> > 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,
> > --
> > Joe
> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>
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" <joeherro@.donotspam.yahoo.com> wrote in message
news:C6C284B8-AF69-4BC3-96A5-9ADBAA210060@.microsoft.com...
> 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" wrote:
>> 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
>>
>>
>>
>> --
>> MY ASP.Net tutorials
>> http://www.openmymind.net/
>>
>> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
>> news:A8C6DC3A-E46D-4918-B38B-3B6FFE4FE4CA@.microsoft.com...
>> > 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,
>> > --
>> > Joe
>>> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
>>
>>
>
Thanks.
--
Joe

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

"Karl Seguin" wrote:

> 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" <joeherro@.donotspam.yahoo.com> wrote in message
> news:C6C284B8-AF69-4BC3-96A5-9ADBAA210060@.microsoft.com...
> > 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" wrote:
> >> 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
> >>
> >>
> >>
> >> --
> >> MY ASP.Net tutorials
> >> http://www.openmymind.net/
> >>
> >> "Joe" <joeherro@.donotspam.yahoo.com> wrote in message
> >> news:A8C6DC3A-E46D-4918-B38B-3B6FFE4FE4CA@.microsoft.com...
> >> > 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,
> >> > --
> >> > Joe
> >> >> > VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
> >>
> >>
> >>
>
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)

"Joe" <joeherro@.donotspam.yahoo.com> wrote in message
news:A8C6DC3A-E46D-4918-B38B-3B6FFE4FE4CA@.microsoft.com...
> 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,
> --
> Joe
> VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

0 comments:

Post a Comment