PC Review


Reply
Thread Tools Rate Thread

C# says Error Creating Control when no ID is specified

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      4th Aug 2008
When using C# for a codebehind language, Design View displays the error
message "Error Creating Control - ctrl type ID property is not specified"
and does not allow you to select the control in Design View. Since it is not
required that an ID is specified (I know that it is needed in order to do
many things, but it is not required for a simple Label with a Text property
that doesn't change, for example), I find this very frustrating. VB.NET does
not display this error, so why is C# displaying it? Thanks.


 
Reply With Quote
 
 
 
 
Ignacio Machin ( .NET/ C# MVP )
Guest
Posts: n/a
 
      4th Aug 2008
On Aug 4, 8:06*am, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:
> When using C# for a codebehind language, Design View displays the error
> message "Error Creating Control - ctrl type ID property is not specified"
> and does not allow you to select the control in Design View. Since it is not
> required that an ID is specified (I know that it is needed in order to do
> many things, but it is not required for a simple Label with a Text property
> that doesn't change, for example), I find this very frustrating. VB.NET does
> not display this error, so why is C# displaying it? Thanks.


Hi,

It might be needed for the designer to work.
Just create an ID and move forward
 
Reply With Quote
 
Stan
Guest
Posts: n/a
 
      6th Aug 2008
On 4 Aug, 13:06, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
wrote:
> When using C# for a codebehind language, Design View displays the error
> message "Error Creating Control - ctrl type ID property is not specified"
> and does not allow you to select the control in Design View. Since it is not
> required that an ID is specified (I know that it is needed in order to do
> many things, but it is not required for a simple Label with a Text property
> that doesn't change, for example), I find this very frustrating. VB.NET does
> not display this error, so why is C# displaying it? Thanks.


Since you don't want the ID property it must be the case that none of
the Label properties change. In which case why use one at all?

Web server controls are mean't to be used for dynamic content.
Anything that is static should be constructed from normal HTML. All
web server controls require extra processing so if they are not needed
they represent an unnecessary overhead.
 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      6th Aug 2008
The Label may have been a bad example. Here are some that may be more
appropriate:

RequiredFieldValidator (and many of the other validators): No extra code is
usually needed in the codebehind and the control is not referenced by any
other controls, so an ID is not necessary.

A Button inside a Repeater's ItemTemplate: When a Button is inside a
databound control's template, it is normally handled by the control's
ItemCommand event and uses the Button's CommandArgument property. The Button
itself, in many cases, is never referenced by it's ID.

I would also like to mention that some controls, such as the Image control,
even though they have HTML tags that do the exact same thing (in this case,
the img tag), they can still be easier. For example, when specifying the
location of the image file, you can use something such as
"~/images/myimagefile.gif" for the Image control's ImageUrl property no
matter what directory the *.aspx file is in, but the img tag's src attribute
requires either "/images/myimagefile.gif" or possibly some ../'s in the
path. Sometimes things like this can be make doing certain things more
convenient, especially when writing things like UserControls (*.ascx) that
may be used in several different directories. But regardless of whether it
is best programming practice or not, DesignView should still be able to show
the control.
--
Nathan Sokalski
(E-Mail Removed)
http://www.nathansokalski.com/

"Stan" <(E-Mail Removed)> wrote in message
news:a6977a40-ff3f-404d-a6e2-(E-Mail Removed)...
> On 4 Aug, 13:06, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
> wrote:
>> When using C# for a codebehind language, Design View displays the error
>> message "Error Creating Control - ctrl type ID property is not specified"
>> and does not allow you to select the control in Design View. Since it is
>> not
>> required that an ID is specified (I know that it is needed in order to do
>> many things, but it is not required for a simple Label with a Text
>> property
>> that doesn't change, for example), I find this very frustrating. VB.NET
>> does
>> not display this error, so why is C# displaying it? Thanks.

>
> Since you don't want the ID property it must be the case that none of
> the Label properties change. In which case why use one at all?
>
> Web server controls are mean't to be used for dynamic content.
> Anything that is static should be constructed from normal HTML. All
> web server controls require extra processing so if they are not needed
> they represent an unnecessary overhead.



 
Reply With Quote
 
Stan
Guest
Posts: n/a
 
      7th Aug 2008
On 6 Aug, 02:03, "Nathan Sokalski" <njsokal...@hotmail.com> wrote:
> The Label may have been a bad example. Here are some that may be more
> appropriate:
>
> RequiredFieldValidator (and many of the other validators): No extra code is
> usually needed in the codebehind and the control is not referenced by any
> other controls, so an ID is not necessary.
>
> A Button inside a Repeater's ItemTemplate: When a Button is inside a
> databound control's template, it is normally handled by the control's
> ItemCommand event and uses the Button's CommandArgument property. The Button
> itself, in many cases, is never referenced by it's ID.
>
> I would also like to mention that some controls, such as the Image control,
> even though they have HTML tags that do the exact same thing (in this case,
> the img tag), they can still be easier. For example, when specifying the
> location of the image file, you can use something such as
> "~/images/myimagefile.gif" for the Image control's ImageUrl property no
> matter what directory the *.aspx file is in, but the img tag's src attribute
> requires either "/images/myimagefile.gif" or possibly some ../'s in the
> path. Sometimes things like this can be make doing certain things more
> convenient, especially when writing things like UserControls (*.ascx) that
> may be used in several different directories. But regardless of whether it
> is best programming practice or not, DesignView should still be able to show
> the control.
> --
> Nathan Sokalski
> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>
> "Stan" <googles...@philhall.net> wrote in message
>
> news:a6977a40-ff3f-404d-a6e2-(E-Mail Removed)...
>
>
>
> > On 4 Aug, 13:06, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
> > wrote:
> >> When using C# for a codebehind language, Design View displays the error
> >> message "Error Creating Control - ctrl type ID property is not specified"
> >> and does not allow you to select the control in Design View. Since it is
> >> not
> >> required that an ID is specified (I know that it is needed in order to do
> >> many things, but it is not required for a simple Label with a Text
> >> property
> >> that doesn't change, for example), I find this very frustrating. VB.NET
> >> does
> >> not display this error, so why is C# displaying it? Thanks.

>
> > Since you don't want the ID property it must be the case that none of
> > the Label properties change. In which case why use one at all?

>
> > Web server controls are mean't to be used for dynamic content.
> > Anything that is static should be constructed from normal HTML. All
> > web server controls require extra processing so if they are not needed
> > they represent an unnecessary overhead.- Hide quoted text -

>
> - Show quoted text -


Nathan

I have tried creating a Label in page source without assigning an ID
in two separate dummy projects. One in VB the other in C#

In both cases they allowed me to switch to design view without error
and showed blank IDs in the properties window.

This is with VS 2008 Framework 3.5. If you are using an earlier
version then maybe MicroSoft has altered it so as to tolerate blank
IDs

On your point about using Image web server controls instead of html
controls inside web user controls, yes I totally agree (I've done that
too and for the same reason) but I don't regard that as a purely
static case. The HTML that is ultimately rendered for the src
attribute (derived from ImagUrl) will depend upon the location of the
host page so it's better to make it an active control.

I apologies if I underestimated your awareness of the issue but I
thought it worth mentioning given the context of your original post.

Stan
 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      7th Aug 2008
No offense taken, I don't always explain myself clearly, so I understand
when I am misunderstood. Anyway, what you said about you using VS 2008 and
..NET 3.5 may be the reason, since i am using VS 2005 and .NET 2.0.

"Stan" <(E-Mail Removed)> wrote in message
news:135dcb78-9594-41f7-b60c-(E-Mail Removed)...
> On 6 Aug, 02:03, "Nathan Sokalski" <njsokal...@hotmail.com> wrote:
>> The Label may have been a bad example. Here are some that may be more
>> appropriate:
>>
>> RequiredFieldValidator (and many of the other validators): No extra code
>> is
>> usually needed in the codebehind and the control is not referenced by any
>> other controls, so an ID is not necessary.
>>
>> A Button inside a Repeater's ItemTemplate: When a Button is inside a
>> databound control's template, it is normally handled by the control's
>> ItemCommand event and uses the Button's CommandArgument property. The
>> Button
>> itself, in many cases, is never referenced by it's ID.
>>
>> I would also like to mention that some controls, such as the Image
>> control,
>> even though they have HTML tags that do the exact same thing (in this
>> case,
>> the img tag), they can still be easier. For example, when specifying the
>> location of the image file, you can use something such as
>> "~/images/myimagefile.gif" for the Image control's ImageUrl property no
>> matter what directory the *.aspx file is in, but the img tag's src
>> attribute
>> requires either "/images/myimagefile.gif" or possibly some ../'s in the
>> path. Sometimes things like this can be make doing certain things more
>> convenient, especially when writing things like UserControls (*.ascx)
>> that
>> may be used in several different directories. But regardless of whether
>> it
>> is best programming practice or not, DesignView should still be able to
>> show
>> the control.
>> --
>> Nathan Sokalski
>> njsokal...@hotmail.comhttp://www.nathansokalski.com/
>>
>> "Stan" <googles...@philhall.net> wrote in message
>>
>> news:a6977a40-ff3f-404d-a6e2-(E-Mail Removed)...
>>
>>
>>
>> > On 4 Aug, 13:06, "Nathan Sokalski" <nsokal...@kyledavidgroup.com>
>> > wrote:
>> >> When using C# for a codebehind language, Design View displays the
>> >> error
>> >> message "Error Creating Control - ctrl type ID property is not
>> >> specified"
>> >> and does not allow you to select the control in Design View. Since it
>> >> is
>> >> not
>> >> required that an ID is specified (I know that it is needed in order to
>> >> do
>> >> many things, but it is not required for a simple Label with a Text
>> >> property
>> >> that doesn't change, for example), I find this very frustrating.
>> >> VB.NET
>> >> does
>> >> not display this error, so why is C# displaying it? Thanks.

>>
>> > Since you don't want the ID property it must be the case that none of
>> > the Label properties change. In which case why use one at all?

>>
>> > Web server controls are mean't to be used for dynamic content.
>> > Anything that is static should be constructed from normal HTML. All
>> > web server controls require extra processing so if they are not needed
>> > they represent an unnecessary overhead.- Hide quoted text -

>>
>> - Show quoted text -

>
> Nathan
>
> I have tried creating a Label in page source without assigning an ID
> in two separate dummy projects. One in VB the other in C#
>
> In both cases they allowed me to switch to design view without error
> and showed blank IDs in the properties window.
>
> This is with VS 2008 Framework 3.5. If you are using an earlier
> version then maybe MicroSoft has altered it so as to tolerate blank
> IDs
>
> On your point about using Image web server controls instead of html
> controls inside web user controls, yes I totally agree (I've done that
> too and for the same reason) but I don't regard that as a purely
> static case. The HTML that is ultimately rendered for the src
> attribute (derived from ImagUrl) will depend upon the location of the
> host page so it's better to make it an active control.
>
> I apologies if I underestimated your awareness of the issue but I
> thought it worth mentioning given the context of your original post.
>
> Stan



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Customer Control Error Creating Control Madison Microsoft ASP .NET 0 23rd Mar 2009 01:59 PM
C# says Error Creating Control when no ID is specified Nathan Sokalski Microsoft C# .NET 5 7th Aug 2008 09:55 PM
Error creating control..Server tag error w/ custom control on webf =?Utf-8?B?RGF2ZQ==?= Microsoft ASP .NET 1 20th Jul 2006 09:39 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau Microsoft ASP .NET 0 1st Jun 2005 03:36 PM
Error Creating Control: Parser Error DocHeader does not have a property named 'cc3:MyItems' ~~~ .NET Ed ~~~ Microsoft ASP .NET 0 10th Nov 2004 05:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:30 PM.