Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Quotes Around Attribute Values - Optional?

Reply
Thread Tools

Quotes Around Attribute Values - Optional?

 
 
Jeremy S
Guest
Posts: n/a
 
      06-13-2009
Both of the following work (i.e., they declare a Web Server control).

<aspropDownList ID=DropDownList1 runat=server></aspropDownList>
<aspropDownList ID="DropDownList2" runat="server"></aspropDownList>

The only difference is that the attribute values are wrapped in quotes, or
they are not wrapped in quoted.

Given that both work (i.e., no compiler or runtime errors), do the quotes
matter for any other purpose? Is there any good reason to include or exclude
the quotes?

Thanks.


 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      06-14-2009
I'm not sure why it is working without the quotes, but whether it works or
not without them you should include them. The reason for this is because
standards specify that all attribute values must be enclosed in quotation
marks. You should notice that if you remove the quotation marks Visual
Studio will give you a validation error. Hopefully this helps.
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/

"Jeremy S" <(E-Mail Removed)> wrote in message
news:u4xYC$(E-Mail Removed)...
> Both of the following work (i.e., they declare a Web Server control).
>
> <aspropDownList ID=DropDownList1 runat=server></aspropDownList>
> <aspropDownList ID="DropDownList2" runat="server"></aspropDownList>
>
> The only difference is that the attribute values are wrapped in quotes, or
> they are not wrapped in quoted.
>
> Given that both work (i.e., no compiler or runtime errors), do the quotes
> matter for any other purpose? Is there any good reason to include or
> exclude the quotes?
>
> Thanks.
>
>



 
Reply With Quote
 
 
 
 
Jeremy S
Guest
Posts: n/a
 
      06-14-2009
What about attributes useful to only to server-side logic?

Clearly, and for example runat="server" never gets rendered to the
browser... consequently DocType and browser standards are not relevant.

Any good "server-side reasons" to include the quotes?

Just curious... I'm not solving any real problem here.

Thanks!



"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> "Jeremy S" <(E-Mail Removed)> wrote in message
> news:u4xYC$(E-Mail Removed)...
>
>> Given that both work (i.e., no compiler or runtime errors), do the quotes
>> matter for any other purpose?

>
> Depends which DOCTYPE you're using. If you're using HTML 4.01, quotes
> round attributes are optional. If you're using XHTML, they're mandatory.
>
>> Is there any good reason to include or exclude the quotes?

>
> Yes, for cross-browser compatibility. Use the XHTML 1.0 Transitional
> DOCTYPE, and set the validation schema in Visual Studio also to be XHTML
> 1.0 Transitional.
>
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net



 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-14-2009
re:
!> What about attributes useful to only to server-side logic?

VS complains if you don't include the quotes.
Otherwise, you can feel free to use quotes or not use them.




Juan T. Llibre, asp.net MVP
¿ Estas probando VS 2010 y ASP.NET 4.0 ?
Regístrate (gratis) en los Foros de VS 2010 y ASP.NET 4.0, en español
http://asp.net.do/foros/forums/
================================================== ===
"Jeremy S" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> What about attributes useful to only to server-side logic?
>
> Clearly, and for example runat="server" never gets rendered to the browser... consequently DocType and browser
> standards are not relevant.
>
> Any good "server-side reasons" to include the quotes?
>
> Just curious... I'm not solving any real problem here.
>
> Thanks!
>
>
>
> "Mark Rae [MVP]" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
>> "Jeremy S" <(E-Mail Removed)> wrote in message news:u4xYC$(E-Mail Removed)...
>>
>>> Given that both work (i.e., no compiler or runtime errors), do the quotes matter for any other purpose?

>>
>> Depends which DOCTYPE you're using. If you're using HTML 4.01, quotes round attributes are optional. If you're using
>> XHTML, they're mandatory.
>>
>>> Is there any good reason to include or exclude the quotes?

>>
>> Yes, for cross-browser compatibility. Use the XHTML 1.0 Transitional DOCTYPE, and set the validation schema in Visual
>> Studio also to be XHTML 1.0 Transitional.
>>
>>
>> --
>> Mark Rae
>> ASP.NET MVP
>> http://www.markrae.net

>
>




 
Reply With Quote
 
Gregory A. Beamer
Guest
Posts: n/a
 
      06-15-2009
"Jeremy S" <(E-Mail Removed)> wrote in
news:u4xYC$(E-Mail Removed):

> Both of the following work (i.e., they declare a Web Server control).
>
> <aspropDownList ID=DropDownList1 runat=server></aspropDownList>
> <aspropDownList ID="DropDownList2"
> runat="server"></aspropDownList>
>
> The only difference is that the attribute values are wrapped in
> quotes, or they are not wrapped in quoted.
>
> Given that both work (i.e., no compiler or runtime errors), do the
> quotes matter for any other purpose? Is there any good reason to
> include or exclude the quotes?



Quotes are proper form and required for some DOCTYPES. And while things
might not "blow up" if you do not use the quotes, you may find your code
not working in the future when MS decides to become more XML compliant
with their output code.

The VS editor, as you move forward in time, gets better at XHTML
compliance and will do more to put in quotes for you. Some third party
tools also put in the quotes, even when VS does not.

The only reason I can see for not putting in quotes, server side or
otherwise, is you are saving two keystrokes per thing you code, but
since there is a potential downside risk, and the time savings for two
strokes is so small, I think it is rather insane not to type them in.


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
 
Jeremy S
Guest
Posts: n/a
 
      06-15-2009
>
> The only reason I can see for not putting in quotes, server side or
> otherwise, is you are saving two keystrokes per thing you code, but
> since there is a potential downside risk, and the time savings for two
> strokes is so small, I think it is rather insane not to type them in.
>



Agreed. - just satisfying a curiosity here, not trying to justify any
lazinesss. Thanks!


 
Reply With Quote
 
Gregory A. Beamer
Guest
Posts: n/a
 
      06-15-2009
"Jeremy S" <(E-Mail Removed)> wrote in news:(E-Mail Removed):

>>
>> The only reason I can see for not putting in quotes, server side or
>> otherwise, is you are saving two keystrokes per thing you code, but
>> since there is a potential downside risk, and the time savings for two
>> strokes is so small, I think it is rather insane not to type them in.
>>

>
>
> Agreed. - just satisfying a curiosity here, not trying to justify any
> lazinesss. Thanks!


No problem. The group is also perused by others that might think not
mentioning it is a bad idea means it is a good idea.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Can I Add quotes to values in a array? or include quotes.. Richard Sandoval Ruby 5 04-26-2011 09:30 PM
PHP double quotes inside double quotes MSB Computer Support 11 10-21-2006 01:09 PM
Asp.NET Javascript string, want to pass '(single quotes' within '(single quotes) Chris ASP .Net 1 03-24-2006 09:03 PM
Quotes/Double Quotes in Image Control Chris White ASP .Net 1 09-22-2004 06:22 AM
Multiline quotes - escaping quotes - et al Lawrence Tierney Java 3 12-24-2003 05:12 PM



Advertisments