473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Referencing HTMLTextArea

I have added an HTMLTextArea object (htaNote) to my
webform.aspx and in the Page_Load codebehind I type
something like:

htaNote.Value = "Ouch!"

Unfortunately, the intellisense does not provide
the .Value for me because it does not recognize the object.

I cannot reference Me.htaNote, either.

If I:
Dim hta As HTMLTextArea

I can:
hta.Value (with Intellisense)

so I tried:
Dim hta As HTNLTextArea
hta = Me.FindControl("htaNote")
hta.Value = "Ouch!"

but this fails since it doesn't find an htaNote object on
the form.

What do I need to reference this object?
Any help would be appreciated.
Nov 17 '05 #1
13 1468
The FindControl Method looks for only those Controls which are immediate
children of the Control referenced. Since the HtmlTextArea is inside your
WebForm, and the WebForm is a child of the Page, you will not find it in the
controls Collection of the Page, but of the WebForm. Therefore, try:

hta = Me.FindControl("Form1").FindControl("htaNote")

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I have added an HTMLTextArea object (htaNote) to my
webform.aspx and in the Page_Load codebehind I type
something like:

htaNote.Value = "Ouch!"

Unfortunately, the intellisense does not provide
the .Value for me because it does not recognize the object.

I cannot reference Me.htaNote, either.

If I:
Dim hta As HTMLTextArea

I can:
hta.Value (with Intellisense)

so I tried:
Dim hta As HTNLTextArea
hta = Me.FindControl("htaNote")
hta.Value = "Ouch!"

but this fails since it doesn't find an htaNote object on
the form.

What do I need to reference this object?
Any help would be appreciated.

Nov 17 '05 #2
The FindControl Method looks for only those Controls which are immediate
children of the Control referenced. Since the HtmlTextArea is inside your
WebForm, and the WebForm is a child of the Page, you will not find it in the
controls Collection of the Page, but of the WebForm. Therefore, try:

hta = Me.FindControl("Form1").FindControl("htaNote")

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I have added an HTMLTextArea object (htaNote) to my
webform.aspx and in the Page_Load codebehind I type
something like:

htaNote.Value = "Ouch!"

Unfortunately, the intellisense does not provide
the .Value for me because it does not recognize the object.

I cannot reference Me.htaNote, either.

If I:
Dim hta As HTMLTextArea

I can:
hta.Value (with Intellisense)

so I tried:
Dim hta As HTNLTextArea
hta = Me.FindControl("htaNote")
hta.Value = "Ouch!"

but this fails since it doesn't find an htaNote object on
the form.

What do I need to reference this object?
Any help would be appreciated.

Nov 17 '05 #3
Your answer makes perfect sense, however I cannot make it
work.

the code:
hta = Me.FindControl("Form1").FindControl("htaNote")

still fails to find an object. The form name is "Form1",
just to make things clear.

Error: Object reference not set to an instance of an
object.

-----Original Message-----
The FindControl Method looks for only those Controls which are immediatechildren of the Control referenced. Since the HtmlTextArea is inside yourWebForm, and the WebForm is a child of the Page, you will not find it in thecontrols Collection of the Page, but of the WebForm. Therefore, try:
hta = Me.FindControl("Form1").FindControl("htaNote")

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in messagenews:03****************************@phx.gbl...
I have added an HTMLTextArea object (htaNote) to my
webform.aspx and in the Page_Load codebehind I type
something like:

htaNote.Value = "Ouch!"

Unfortunately, the intellisense does not provide
the .Value for me because it does not recognize the object.
I cannot reference Me.htaNote, either.

If I:
Dim hta As HTMLTextArea

I can:
hta.Value (with Intellisense)

so I tried:
Dim hta As HTNLTextArea
hta = Me.FindControl("htaNote")
hta.Value = "Ouch!"

but this fails since it doesn't find an htaNote object on the form.

What do I need to reference this object?
Any help would be appreciated.

.

Nov 17 '05 #4
Your answer makes perfect sense, however I cannot make it
work.

the code:
hta = Me.FindControl("Form1").FindControl("htaNote")

still fails to find an object. The form name is "Form1",
just to make things clear.

Error: Object reference not set to an instance of an
object.

-----Original Message-----
The FindControl Method looks for only those Controls which are immediatechildren of the Control referenced. Since the HtmlTextArea is inside yourWebForm, and the WebForm is a child of the Page, you will not find it in thecontrols Collection of the Page, but of the WebForm. Therefore, try:
hta = Me.FindControl("Form1").FindControl("htaNote")

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in messagenews:03****************************@phx.gbl...
I have added an HTMLTextArea object (htaNote) to my
webform.aspx and in the Page_Load codebehind I type
something like:

htaNote.Value = "Ouch!"

Unfortunately, the intellisense does not provide
the .Value for me because it does not recognize the object.
I cannot reference Me.htaNote, either.

If I:
Dim hta As HTMLTextArea

I can:
hta.Value (with Intellisense)

so I tried:
Dim hta As HTNLTextArea
hta = Me.FindControl("htaNote")
hta.Value = "Ouch!"

but this fails since it doesn't find an htaNote object on the form.

What do I need to reference this object?
Any help would be appreciated.

.

Nov 17 '05 #5
Well, you were using a rather unusual method of declaring your Control; I
wasn't sure whether it would work. What you need to do is to declare the
Control in your CodeBehind class as a field of the Page class:

Protected htaNote As System.Web.UI.HtmlControls.HtmlTextarea

That will wire it up to the Control in the Template. Then you can reference
it and work with it in your Page_Load Sub. Assuming that the id of the
Control in the Template matches the name of the Control in the declaration.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Your answer makes perfect sense, however I cannot make it
work.

the code:
hta = Me.FindControl("Form1").FindControl("htaNote")

still fails to find an object. The form name is "Form1",
just to make things clear.

Error: Object reference not set to an instance of an
object.

-----Original Message-----
The FindControl Method looks for only those Controls

which are immediate
children of the Control referenced. Since the

HtmlTextArea is inside your
WebForm, and the WebForm is a child of the Page, you will

not find it in the
controls Collection of the Page, but of the WebForm.

Therefore, try:

hta = Me.FindControl("Form1").FindControl("htaNote")

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in

message
news:03****************************@phx.gbl...
I have added an HTMLTextArea object (htaNote) to my
webform.aspx and in the Page_Load codebehind I type
something like:

htaNote.Value = "Ouch!"

Unfortunately, the intellisense does not provide
the .Value for me because it does not recognize the object.
I cannot reference Me.htaNote, either.

If I:
Dim hta As HTMLTextArea

I can:
hta.Value (with Intellisense)

so I tried:
Dim hta As HTNLTextArea
hta = Me.FindControl("htaNote")
hta.Value = "Ouch!"

but this fails since it doesn't find an htaNote object on the form.

What do I need to reference this object?
Any help would be appreciated.

.

Nov 17 '05 #6
Well, you were using a rather unusual method of declaring your Control; I
wasn't sure whether it would work. What you need to do is to declare the
Control in your CodeBehind class as a field of the Page class:

Protected htaNote As System.Web.UI.HtmlControls.HtmlTextarea

That will wire it up to the Control in the Template. Then you can reference
it and work with it in your Page_Load Sub. Assuming that the id of the
Control in the Template matches the name of the Control in the declaration.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Your answer makes perfect sense, however I cannot make it
work.

the code:
hta = Me.FindControl("Form1").FindControl("htaNote")

still fails to find an object. The form name is "Form1",
just to make things clear.

Error: Object reference not set to an instance of an
object.

-----Original Message-----
The FindControl Method looks for only those Controls

which are immediate
children of the Control referenced. Since the

HtmlTextArea is inside your
WebForm, and the WebForm is a child of the Page, you will

not find it in the
controls Collection of the Page, but of the WebForm.

Therefore, try:

hta = Me.FindControl("Form1").FindControl("htaNote")

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in

message
news:03****************************@phx.gbl...
I have added an HTMLTextArea object (htaNote) to my
webform.aspx and in the Page_Load codebehind I type
something like:

htaNote.Value = "Ouch!"

Unfortunately, the intellisense does not provide
the .Value for me because it does not recognize the object.
I cannot reference Me.htaNote, either.

If I:
Dim hta As HTMLTextArea

I can:
hta.Value (with Intellisense)

so I tried:
Dim hta As HTNLTextArea
hta = Me.FindControl("htaNote")
hta.Value = "Ouch!"

but this fails since it doesn't find an htaNote object on the form.

What do I need to reference this object?
Any help would be appreciated.

.

Nov 17 '05 #7
Again, your logic is solid and looks like it should work.

I added:
Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextarea

in the #Region bewteen "Private Sub InitializeComponent()"
and "Private designerPlaceholderDeclaration As
System.Object"

so my code in #Region now reads:
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextArea

'NOTE: The following placeholder declaration is
required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web
Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

This allows me to have intellisense on htaNote, however I
still get the same error when I run the code.

I find it odd that .NET does not add the "Protected
htaNote..." itself, as it does for other objects.

Still lost,
Will
-----Original Message-----
Well, you were using a rather unusual method of declaring your Control; Iwasn't sure whether it would work. What you need to do is to declare theControl in your CodeBehind class as a field of the Page class:
Protected htaNote As System.Web.UI.HtmlControls.HtmlTextarea
That will wire it up to the Control in the Template. Then you can referenceit and work with it in your Page_Load Sub. Assuming that the id of theControl in the Template matches the name of the Control in the declaration.
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl...
Your answer makes perfect sense, however I cannot make it work.

the code:
hta = Me.FindControl("Form1").FindControl("htaNote")

still fails to find an object. The form name is "Form1",
just to make things clear.

Error: Object reference not set to an instance of an
object.

>-----Original Message-----
>The FindControl Method looks for only those Controls

which are immediate
>children of the Control referenced. Since the

HtmlTextArea is inside your
>WebForm, and the WebForm is a child of the Page, you
will not find it in the
>controls Collection of the Page, but of the WebForm.

Therefore, try:
>
>hta = Me.FindControl("Form1").FindControl("htaNote")
>
>--
>HTH,
>
>Kevin Spencer
>Microsoft MVP
>..Net Developer
>http://www.takempis.com
>Big Things are made up of
>Lots of Little Things.
>
>"Will T" <an*******@discussions.microsoft.com> wrote in

message
>news:03****************************@phx.gbl...
>> I have added an HTMLTextArea object (htaNote) to my
>> webform.aspx and in the Page_Load codebehind I type
>> something like:
>>
>> htaNote.Value = "Ouch!"
>>
>> Unfortunately, the intellisense does not provide
>> the .Value for me because it does not recognize the

object.
>>
>> I cannot reference Me.htaNote, either.
>>
>> If I:
>> Dim hta As HTMLTextArea
>>
>> I can:
>> hta.Value (with Intellisense)
>>
>> so I tried:
>> Dim hta As HTNLTextArea
>> hta = Me.FindControl("htaNote")
>> hta.Value = "Ouch!"
>>
>> but this fails since it doesn't find an htaNote
object on
>> the form.
>>
>> What do I need to reference this object?
>> Any help would be appreciated.
>
>
>.
>

.

Nov 17 '05 #8
BTW, I have also placed the "Protected htaNote..." above
the #Region, with the same results.

-Will
-----Original Message-----
Again, your logic is solid and looks like it should work.

I added:
Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextarea

in the #Region bewteen "Private Sub InitializeComponent ()"and "Private designerPlaceholderDeclaration As
System.Object"

so my code in #Region now reads:
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private SubInitializeComponent()

End Sub
Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextArea

'NOTE: The following placeholder declaration is
required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web
Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

This allows me to have intellisense on htaNote, however I
still get the same error when I run the code.

I find it odd that .NET does not add the "Protected
htaNote..." itself, as it does for other objects.

Still lost,
Will
-----Original Message-----
Well, you were using a rather unusual method of declaring
your Control; I
wasn't sure whether it would work. What you need to do
isto declare the
Control in your CodeBehind class as a field of the Pageclass:

Protected htaNote As

System.Web.UI.HtmlControls.HtmlTextarea

That will wire it up to the Control in the Template.

Thenyou can reference
it and work with it in your Page_Load Sub. Assuming that

the id of the
Control in the Template matches the name of the Control

in the declaration.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in

message
news:04****************************@phx.gbl...
Your answer makes perfect sense, however I cannot make

it work.

the code:
hta = Me.FindControl("Form1").FindControl("htaNote")

still fails to find an object. The form name is "Form1", just to make things clear.

Error: Object reference not set to an instance of an
object.
>-----Original Message-----
>The FindControl Method looks for only those Controls
which are immediate
>children of the Control referenced. Since the
HtmlTextArea is inside your
>WebForm, and the WebForm is a child of the Page, youwill not find it in the
>controls Collection of the Page, but of the WebForm.
Therefore, try:
>
>hta = Me.FindControl("Form1").FindControl("htaNote")
>
>--
>HTH,
>
>Kevin Spencer
>Microsoft MVP
>..Net Developer
>http://www.takempis.com
>Big Things are made up of
>Lots of Little Things.
>
>"Will T" <an*******@discussions.microsoft.com> wrote in message
>news:03****************************@phx.gbl...
>> I have added an HTMLTextArea object (htaNote) to my
>> webform.aspx and in the Page_Load codebehind I type
>> something like:
>>
>> htaNote.Value = "Ouch!"
>>
>> Unfortunately, the intellisense does not provide
>> the .Value for me because it does not recognize the
object.
>>
>> I cannot reference Me.htaNote, either.
>>
>> If I:
>> Dim hta As HTMLTextArea
>>
>> I can:
>> hta.Value (with Intellisense)
>>
>> so I tried:
>> Dim hta As HTNLTextArea
>> hta = Me.FindControl("htaNote")
>> hta.Value = "Ouch!"
>>
>> but this fails since it doesn't find an htaNoteobject on
>> the form.
>>
>> What do I need to reference this object?
>> Any help would be appreciated.
>
>
>.
>

.

.

Nov 17 '05 #9
What software are you using to develop with? Visual Studio.Net will add the
property declaration for you when you either drag a Control onto the Page
template or make a Control "runat=server".

What does the tag in the Page Template look like? It has to be some problem
with the correspondence between the tag in the Template and the property
declaration. the property declaration is correct. And I'm assuming you took
the Dim statement out.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <wi*********@tailoredsoft.com> wrote in message
news:09****************************@phx.gbl...
Again, your logic is solid and looks like it should work.

I added:
Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextarea

in the #Region bewteen "Private Sub InitializeComponent()"
and "Private designerPlaceholderDeclaration As
System.Object"

so my code in #Region now reads:
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextArea

'NOTE: The following placeholder declaration is
required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web
Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

This allows me to have intellisense on htaNote, however I
still get the same error when I run the code.

I find it odd that .NET does not add the "Protected
htaNote..." itself, as it does for other objects.

Still lost,
Will
-----Original Message-----
Well, you were using a rather unusual method of declaring

your Control; I
wasn't sure whether it would work. What you need to do is

to declare the
Control in your CodeBehind class as a field of the Page

class:

Protected htaNote As

System.Web.UI.HtmlControls.HtmlTextarea

That will wire it up to the Control in the Template. Then

you can reference
it and work with it in your Page_Load Sub. Assuming that

the id of the
Control in the Template matches the name of the Control

in the declaration.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in

message
news:04****************************@phx.gbl...
Your answer makes perfect sense, however I cannot make it work.

the code:
hta = Me.FindControl("Form1").FindControl("htaNote")

still fails to find an object. The form name is "Form1",
just to make things clear.

Error: Object reference not set to an instance of an
object.
>-----Original Message-----
>The FindControl Method looks for only those Controls
which are immediate
>children of the Control referenced. Since the
HtmlTextArea is inside your
>WebForm, and the WebForm is a child of the Page, you will not find it in the
>controls Collection of the Page, but of the WebForm.
Therefore, try:
>
>hta = Me.FindControl("Form1").FindControl("htaNote")
>
>--
>HTH,
>
>Kevin Spencer
>Microsoft MVP
>..Net Developer
>http://www.takempis.com
>Big Things are made up of
>Lots of Little Things.
>
>"Will T" <an*******@discussions.microsoft.com> wrote in
message
>news:03****************************@phx.gbl...
>> I have added an HTMLTextArea object (htaNote) to my
>> webform.aspx and in the Page_Load codebehind I type
>> something like:
>>
>> htaNote.Value = "Ouch!"
>>
>> Unfortunately, the intellisense does not provide
>> the .Value for me because it does not recognize the
object.
>>
>> I cannot reference Me.htaNote, either.
>>
>> If I:
>> Dim hta As HTMLTextArea
>>
>> I can:
>> hta.Value (with Intellisense)
>>
>> so I tried:
>> Dim hta As HTNLTextArea
>> hta = Me.FindControl("htaNote")
>> hta.Value = "Ouch!"
>>
>> but this fails since it doesn't find an htaNote object on
>> the form.
>>
>> What do I need to reference this object?
>> Any help would be appreciated.
>
>
>.
>

.

Nov 17 '05 #10
Firstly, thanks for the help you are providing.

I am developing in VS.NET 2003. To reproduce this
situation, follow these steps:

1) Add a Webform to a web project (WebForm1.aspx)
2) In the Toolbox, click the HTML tab.
3) Drag an HTMLTextArea object to the screen.
4) Open it's properties and name it "DOG" (id="DOG")
5) Open the Code view
6) Perform a search for "DOG".

Mine yields no results.

7) Open the HTML view
8) Search for "DOG" again.

Mine finds the object:
<TEXTAREA id="dog" style="Z-INDEX: 103;
LEFT:24px;POSITION: absolute; TOP: 80px" rows="2"
cols="20"></TEXTAREA>

No reference in the webform, but one in the HTML. I am
lost.

-Will

-----Original Message-----
What software are you using to develop with? Visual Studio.Net will add theproperty declaration for you when you either drag a Control onto the Pagetemplate or make a Control "runat=server".

What does the tag in the Page Template look like? It has to be some problemwith the correspondence between the tag in the Template and the propertydeclaration. the property declaration is correct. And I'm assuming you tookthe Dim statement out.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <wi*********@tailoredsoft.com> wrote in message
news:09****************************@phx.gbl...
Again, your logic is solid and looks like it should work.
I added:
Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextarea

in the #Region bewteen "Private Sub InitializeComponent ()" and "Private designerPlaceholderDeclaration As
System.Object"

so my code in #Region now reads:
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextArea

'NOTE: The following placeholder declaration is
required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

This allows me to have intellisense on htaNote, however I still get the same error when I run the code.

I find it odd that .NET does not add the "Protected
htaNote..." itself, as it does for other objects.

Still lost,
Will
>-----Original Message-----
>Well, you were using a rather unusual method of declaring
your Control; I
>wasn't sure whether it would work. What you need to do
is to declare the
>Control in your CodeBehind class as a field of the Page

class:
>
>Protected htaNote As

System.Web.UI.HtmlControls.HtmlTextarea
>
>That will wire it up to the Control in the Template.
Then you can reference
>it and work with it in your Page_Load Sub. Assuming
that the id of the
>Control in the Template matches the name of the Control

in the declaration.
>
>--
>HTH,
>
>Kevin Spencer
>Microsoft MVP
>..Net Developer
>http://www.takempis.com
>Big Things are made up of
>Lots of Little Things.
>
>"Will T" <an*******@discussions.microsoft.com> wrote in

message
>news:04****************************@phx.gbl...
>> Your answer makes perfect sense, however I cannot
make it
>> work.
>>
>> the code:
>> hta = Me.FindControl("Form1").FindControl("htaNote")
>>
>> still fails to find an object. The form name

is "Form1", >> just to make things clear.
>>
>> Error: Object reference not set to an instance of an
>> object.
>>
>>
>> >-----Original Message-----
>> >The FindControl Method looks for only those Controls
>> which are immediate
>> >children of the Control referenced. Since the
>> HtmlTextArea is inside your
>> >WebForm, and the WebForm is a child of the Page, you

will
>> not find it in the
>> >controls Collection of the Page, but of the WebForm.
>> Therefore, try:
>> >
>> >hta = Me.FindControl("Form1").FindControl("htaNote")
>> >
>> >--
>> >HTH,
>> >
>> >Kevin Spencer
>> >Microsoft MVP
>> >..Net Developer
>> >http://www.takempis.com
>> >Big Things are made up of
>> >Lots of Little Things.
>> >
>> >"Will T" <an*******@discussions.microsoft.com> wrote in >> message
>> >news:03****************************@phx.gbl...
>> >> I have added an HTMLTextArea object (htaNote) to my >> >> webform.aspx and in the Page_Load codebehind I type >> >> something like:
>> >>
>> >> htaNote.Value = "Ouch!"
>> >>
>> >> Unfortunately, the intellisense does not provide
>> >> the .Value for me because it does not recognize the >> object.
>> >>
>> >> I cannot reference Me.htaNote, either.
>> >>
>> >> If I:
>> >> Dim hta As HTMLTextArea
>> >>
>> >> I can:
>> >> hta.Value (with Intellisense)
>> >>
>> >> so I tried:
>> >> Dim hta As HTNLTextArea
>> >> hta = Me.FindControl("htaNote")
>> >> hta.Value = "Ouch!"
>> >>
>> >> but this fails since it doesn't find an htaNote

object
>> on
>> >> the form.
>> >>
>> >> What do I need to reference this object?
>> >> Any help would be appreciated.
>> >
>> >
>> >.
>> >
>
>
>.
>

.

Nov 17 '05 #11
Ah, the light is coming on now!

If you're dragging an HTML TextArea from the ToolBox, you are not creating
an HTMLControl, you are creating an HTML Textarea. To have it become an
HTMLControl, you can right-click it in the Designer, and select "run as
server control" from the context menu. Then the IDE will create the
CodeBehind Reference.

Alternatively, you can add a "runat=server" attribute in the HTML View,
assign an ID to it, and switch back to Designer view. When you switch back
to Designer view, it adds the CodeBehind for the Control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Firstly, thanks for the help you are providing.

I am developing in VS.NET 2003. To reproduce this
situation, follow these steps:

1) Add a Webform to a web project (WebForm1.aspx)
2) In the Toolbox, click the HTML tab.
3) Drag an HTMLTextArea object to the screen.
4) Open it's properties and name it "DOG" (id="DOG")
5) Open the Code view
6) Perform a search for "DOG".

Mine yields no results.

7) Open the HTML view
8) Search for "DOG" again.

Mine finds the object:
<TEXTAREA id="dog" style="Z-INDEX: 103;
LEFT:24px;POSITION: absolute; TOP: 80px" rows="2"
cols="20"></TEXTAREA>

No reference in the webform, but one in the HTML. I am
lost.

-Will

-----Original Message-----
What software are you using to develop with? Visual

Studio.Net will add the
property declaration for you when you either drag a

Control onto the Page
template or make a Control "runat=server".

What does the tag in the Page Template look like? It has

to be some problem
with the correspondence between the tag in the Template

and the property
declaration. the property declaration is correct. And I'm

assuming you took
the Dim statement out.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <wi*********@tailoredsoft.com> wrote in message
news:09****************************@phx.gbl...
Again, your logic is solid and looks like it should work.
I added:
Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextarea

in the #Region bewteen "Private Sub InitializeComponent ()" and "Private designerPlaceholderDeclaration As
System.Object"

so my code in #Region now reads:
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub
Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextArea

'NOTE: The following placeholder declaration is
required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

This allows me to have intellisense on htaNote, however I still get the same error when I run the code.

I find it odd that .NET does not add the "Protected
htaNote..." itself, as it does for other objects.

Still lost,
Will
>-----Original Message-----
>Well, you were using a rather unusual method of declaring your Control; I
>wasn't sure whether it would work. What you need to do is to declare the
>Control in your CodeBehind class as a field of the Page
class:
>
>Protected htaNote As
System.Web.UI.HtmlControls.HtmlTextarea
>
>That will wire it up to the Control in the Template. Then you can reference
>it and work with it in your Page_Load Sub. Assuming that the id of the
>Control in the Template matches the name of the Control
in the declaration.
>
>--
>HTH,
>
>Kevin Spencer
>Microsoft MVP
>..Net Developer
>http://www.takempis.com
>Big Things are made up of
>Lots of Little Things.
>
>"Will T" <an*******@discussions.microsoft.com> wrote in
message
>news:04****************************@phx.gbl...
>> Your answer makes perfect sense, however I cannot make it
>> work.
>>
>> the code:
>> hta = Me.FindControl("Form1").FindControl("htaNote")
>>
>> still fails to find an object. The form name is "Form1", >> just to make things clear.
>>
>> Error: Object reference not set to an instance of an
>> object.
>>
>>
>> >-----Original Message-----
>> >The FindControl Method looks for only those Controls
>> which are immediate
>> >children of the Control referenced. Since the
>> HtmlTextArea is inside your
>> >WebForm, and the WebForm is a child of the Page, you
will
>> not find it in the
>> >controls Collection of the Page, but of the WebForm.
>> Therefore, try:
>> >
>> >hta = Me.FindControl("Form1").FindControl("htaNote")
>> >
>> >--
>> >HTH,
>> >
>> >Kevin Spencer
>> >Microsoft MVP
>> >..Net Developer
>> >http://www.takempis.com
>> >Big Things are made up of
>> >Lots of Little Things.
>> >
>> >"Will T" <an*******@discussions.microsoft.com> wrote in >> message
>> >news:03****************************@phx.gbl...
>> >> I have added an HTMLTextArea object (htaNote) to my >> >> webform.aspx and in the Page_Load codebehind I type >> >> something like:
>> >>
>> >> htaNote.Value = "Ouch!"
>> >>
>> >> Unfortunately, the intellisense does not provide
>> >> the .Value for me because it does not recognize the >> object.
>> >>
>> >> I cannot reference Me.htaNote, either.
>> >>
>> >> If I:
>> >> Dim hta As HTMLTextArea
>> >>
>> >> I can:
>> >> hta.Value (with Intellisense)
>> >>
>> >> so I tried:
>> >> Dim hta As HTNLTextArea
>> >> hta = Me.FindControl("htaNote")
>> >> hta.Value = "Ouch!"
>> >>
>> >> but this fails since it doesn't find an htaNote
object
>> on
>> >> the form.
>> >>
>> >> What do I need to reference this object?
>> >> Any help would be appreciated.
>> >
>> >
>> >.
>> >
>
>
>.
>

.

Nov 17 '05 #12
Jiminy Crickets! It worked! I owe you lunch.

I was leary about making the objects "Run at Server". You
see, the whole point of this is that I need a text field
and a counter. As the user types in the text field, the
counter needs to reflect the number of characters typed. I
am doing this via javascript.

Using an HTMLTextArea, I was able to do this. The catch
was that I could not preload any data into the
HTMLTextArea (which is what you helped me resolve).

My fear was that by making the object "Run at Server" it
would require a postback with each character typed. On the
development machine, this has not been the case. I will
try to deploy the app and test it via the web, for the
real test.

Thanks again,
Will
-----Original Message-----
Ah, the light is coming on now!

If you're dragging an HTML TextArea from the ToolBox, you are not creatingan HTMLControl, you are creating an HTML Textarea. To have it become anHTMLControl, you can right-click it in the Designer, and select "run asserver control" from the context menu. Then the IDE will create theCodeBehind Reference.

Alternatively, you can add a "runat=server" attribute in the HTML View,assign an ID to it, and switch back to Designer view. When you switch backto Designer view, it adds the CodeBehind for the Control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in messagenews:04****************************@phx.gbl...
Firstly, thanks for the help you are providing.

I am developing in VS.NET 2003. To reproduce this
situation, follow these steps:

1) Add a Webform to a web project (WebForm1.aspx)
2) In the Toolbox, click the HTML tab.
3) Drag an HTMLTextArea object to the screen.
4) Open it's properties and name it "DOG" (id="DOG")
5) Open the Code view
6) Perform a search for "DOG".

Mine yields no results.

7) Open the HTML view
8) Search for "DOG" again.

Mine finds the object:
<TEXTAREA id="dog" style="Z-INDEX: 103;
LEFT:24px;POSITION: absolute; TOP: 80px" rows="2"
cols="20">

Nov 17 '05 #13
Exzcellent, Dude!
My fear was that by making the object "Run at Server" it
would require a postback with each character typed. On the
development machine, this has not been the case. I will
try to deploy the app and test it via the web, for the
real test.
No problem there. An HtmlTextArea Control doesn't have any server-side
events by default. In fact, I think you'd have to jump through some hoops to
make it generate one.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in message
news:07****************************@phx.gbl... Jiminy Crickets! It worked! I owe you lunch.

I was leary about making the objects "Run at Server". You
see, the whole point of this is that I need a text field
and a counter. As the user types in the text field, the
counter needs to reflect the number of characters typed. I
am doing this via javascript.

Using an HTMLTextArea, I was able to do this. The catch
was that I could not preload any data into the
HTMLTextArea (which is what you helped me resolve).

My fear was that by making the object "Run at Server" it
would require a postback with each character typed. On the
development machine, this has not been the case. I will
try to deploy the app and test it via the web, for the
real test.

Thanks again,
Will
-----Original Message-----
Ah, the light is coming on now!

If you're dragging an HTML TextArea from the ToolBox, you

are not creating
an HTMLControl, you are creating an HTML Textarea. To

have it become an
HTMLControl, you can right-click it in the Designer, and

select "run as
server control" from the context menu. Then the IDE will

create the
CodeBehind Reference.

Alternatively, you can add a "runat=server" attribute in

the HTML View,
assign an ID to it, and switch back to Designer view.

When you switch back
to Designer view, it adds the CodeBehind for the Control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Will T" <an*******@discussions.microsoft.com> wrote in

message
news:04****************************@phx.gbl...
Firstly, thanks for the help you are providing.

I am developing in VS.NET 2003. To reproduce this
situation, follow these steps:

1) Add a Webform to a web project (WebForm1.aspx)
2) In the Toolbox, click the HTML tab.
3) Drag an HTMLTextArea object to the screen.
4) Open it's properties and name it "DOG" (id="DOG")
5) Open the Code view
6) Perform a search for "DOG".

Mine yields no results.

7) Open the HTML view
8) Search for "DOG" again.

Mine finds the object:
<TEXTAREA id="dog" style="Z-INDEX: 103;
LEFT:24px;POSITION: absolute; TOP: 80px" rows="2"
cols="20">

Nov 17 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Will T | last post by:
I have added an HTMLTextArea object (htaNote) to my webform.aspx and in the Page_Load codebehind I type something like: htaNote.Value = "Ouch!" Unfortunately, the intellisense does not...
3
by: Michael SL | last post by:
I have a text area in which I have a client side javascript to process a "onclick". Because it is client side, I used a HtmlTextArea <TextArea id="Summary" onmouseup="SumMouseUp()" style="WIDTH:...
8
by: Chris | last post by:
Hi, i have in an content page a fieldset containing a label, an iframe and a textarea: <asp:Content ID="Content1" ContentPlaceHolderID="main" Runat="Server"> <fieldset style="width:650px;">...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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,...

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.