Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   C# says Error Creating Control when no ID is specified (http://www.velocityreviews.com/forums/t629076-c-says-error-creating-control-when-no-id-is-specified.html)

Nathan Sokalski 08-04-2008 12:06 PM

C# says Error Creating Control when no ID is specified
 
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.



Ignacio Machin ( .NET/ C# MVP ) 08-04-2008 02:33 PM

Re: C# says Error Creating Control when no ID is specified
 
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

Stan 08-06-2008 12:25 AM

Re: C# says Error Creating Control when no ID is specified
 
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.

Nathan Sokalski 08-06-2008 01:03 AM

Re: C# says Error Creating Control when no ID is specified
 
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
njsokalski@hotmail.com
http://www.nathansokalski.com/

"Stan" <googlestan@philhall.net> wrote in message
news:a6977a40-ff3f-404d-a6e2-a10895bd5312@26g2000hsk.googlegroups.com...
> 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.




Stan 08-07-2008 10:15 AM

Re: C# says Error Creating Control when no ID is specified
 
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-a10895bd5312@26g2000hsk.googlegroups.com...
>
>
>
> > 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

Nathan Sokalski 08-07-2008 08:55 PM

Re: C# says Error Creating Control when no ID is specified
 
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" <googlestan@philhall.net> wrote in message
news:135dcb78-9594-41f7-b60c-6e2b9c2d6042@f63g2000hsf.googlegroups.com...
> 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-a10895bd5312@26g2000hsk.googlegroups.com...
>>
>>
>>
>> > 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





All times are GMT. The time now is 12:16 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.