this is the difference:
Some of the XHTML rules that differ from HTML include the following:
a.. All elements either include an explicit closing tag or are
self-closing (with />).
b.. Tag and attribute names are rendered in lowercase, and attribute
values are included in double quotation marks. For example, if you use a
System.Web.UI.WebControls.GridView control on your page, when the page is
rendered, the System.Web.UI.WebControls.GridView control emits HTML that is
XHTML compliant. All generated elements use explicit opening and closing
tags (or self-closing tags), and attribute values are included in double
quotation marks.
c.. Formatting information is rendered using only cascading style sheet
styler. To support this standard, ASP.NET controls do not render <font> tags
or attributes such as bgcolor.
d.. Controls do not render custom attributes (expando attributes) that are
not defined in the XHTML standards.
e.. In ASP.NET, if controls generate IDs, as occurs in the Repeater,
GridView, and other controls, the format of the IDs is XHTML 1.1 compliant.
f.. ASP.NET dynamically adds an action attribute to the form tag. Because
XHTML 1.1 prohibits it, form tags do not include a name attribute.
g.. Because XHTML requires all elements to be enclosed in a container
element, ASP.NET controls such as input elements are rendered in div
elements. This includes the HTML markup rendered for controls such as the
TextBox, CheckBox, and RadioButton controls. It also includes hidden fields,
such as the element used to store view-state data.
h.. ASP.NET codes characters such as & (for example, as &). This
includes URLs that are generated to reference JavaScript script and the
contents of encoded values such as view state.
i.. Any script tags rendered into the page include an appropriate type
attribute. (This pertains to scripts that are created by the page or
controls or by the RegisterHiddenField, RegisterStartupScript, and
RegisterClientScriptBlock methods; script blocks that you create are not
automatically amended with a type attribute.) In ASP.NET any script tags
rendered by the page use the appropriate type attribute
(type="type/javascript") and do not include a language attribute. ASP.NET
renders script tags when the page includes certain controls (such as the
System.Web.UI.WebControls.HyperLink , System.Web.UI.WebControls.LinkButton ,
and System.Web.UI.WebControls.Calendar controls) that require client script
to perform a postback. Script is also rendered for controls that rely on
client-side functionality, such as the System.Web.UI.WebControls.TreeView
and validator controls.
j.. IF ASP.NET renders script blocks, the contents of the script blocks is
rendered in CDATA elements (inside <![CDATA[ and ]]> tags) to prevent
special characters such as & and < from being interpreted as XML.
"Patrice" <nobody@nowhere.com> wrote in message
news:u9FC%23MgYFHA.3488@tk2msftngp13.phx.gbl...[color=blue]
> Yes this is what I meant...
>
> I don't see what difference you ake between "XHTML" and "HTML" encoded
> scripts...
>
> For example the problme seems to be related to & being &
>
> What if you try just :
>
> TextBox1.Attributes.Add("onkeydown","alert(8 && 4);")
>
> Even if it is rendered as :
> onkeydown="alert(8 && 4);" does it work as expected ?
>
> Patrice
>
>
> --
>
> "Alex D." <alexware69@hotmail.com> a écrit dans le message de
> news:OBsL35fYFHA.3380@TK2MSFTNGP10.phx.gbl...[color=green]
>> HTML enconded javascript woks fine here too.... what doesn't work fine is
>> XHTML encoded javascript....
>> If I use Me.ClientScript.RegisterClientScriptBlock then I guess I need to
>> create a whole function() and then call the function from[/color]
> attributes.add...[color=green]
>> is that right?
>>
>>
>> "Patrice" <nobody@nowhere.com> wrote in message
>> news:%237F0IyfYFHA.2076@TK2MSFTNGP15.phx.gbl...[color=darkred]
>> > What I meant was to use Me.ClientScript.RegisterClientScriptBlock to
>> > render
>> > the script and then use attributes.add just to call it... AFAIK scripts
>> > registered his way are not encoded (the trick is that this function[/color][/color]
> knows[color=green][color=darkred]
>> > this a script while attributes.add doesn't know what you are doing).
>> >
>> > What browser are you using ? Here HTML encoded JavaScript code seems to
>> > work
>> > fine...
>> >
>> > Hope I'm clearer...
>> >
>> > Patrice
>> >
>> > --
>> >
>> > "Alex D." <alexware69@hotmail.com> a écrit dans le message de
>> > news:OOMB4rfYFHA.3712@TK2MSFTNGP10.phx.gbl...
>> >> my friend, I get the same problem even if I insert the code here:
>> >>
>> >> <FORM id=Form1 method=post runat="server" onload=
>> >> "if((event.which && event.which== 13)||(event.keyCode && event.keyCode[/color][/color]
> ==[color=green][color=darkred]
>> >> 13)){document.Form1.cmdLogin.click();return false;}else return[/color][/color]
> true;");>[color=green][color=darkred]
>> >>
>> >> but if I insert the code BEFORE the FORM tag , let say, inside the[/color][/color]
> BODY,[color=green][color=darkred]
>> >> then it render & instead of & which is OK. SO it is an XHTML[/color][/color]
> related[color=green][color=darkred]
>> >> problem
>> >>
>> >> If you are interested you can read this, I tried the suggested
>> >> solution[/color][/color]
>[color=green][color=darkred]
>> >> to
>> >> disable XHTML but it didn't work.
>> >>
>> >> ASP.NET and XHTML Compliance
>> >> ASP.NET allows you to create Web pages that are compliant with XHTML[/color][/color]
> 1.1[color=green][color=darkred]
>> >> standards. XHTML is a W3C standard that defines HTML as an XML[/color][/color]
> document.[color=green][color=darkred]
>> >> Creating Web pages that are conformant with XHTML standards guarantees
>> > that
>> >> the elements in the pages are well formed. Because many browsers are
>> > moving
>> >> toward supporting XHTML, creating pages that conform to XHTML
>> >> standards
>> >> helps ensure that your pages will be compatible with browsers in the
>> > future.
>> >> XHTML is also extensible, allowing the definition of new elements.
>> > Finally,
>> >> an XHTML page is much easier to read programmatically for situations
>> >> in
>> >> which the Web page is processed by a computer rather than read by[/color][/color]
> users,[color=green][color=darkred]
>> > and
>> >> the document can be manipulated using transformations. For more
>> > information
>> >> about the XHTML standard, see the W3C site at
www.w3.org/TR/xhtml1.
>> >>
>> >> Compliance Features
>> >> XHTML defines elements and attributes more strictly than HTML. By
>> >> default,
>> >> all markup produced by ASP.NET and Web server controls included with
>> > ASP.NET
>> >> now conforms to this standard.
>> >>
>> >> Some of the XHTML rules that differ from HTML include the following:
>> >>
>> >> a.. All elements either include an explicit closing tag or are
>> >> self-closing (with />).
>> >>
>> >> b.. Tag and attribute names are rendered in lowercase, and attribute
>> >> values are included in double quotation marks. For example, if you use[/color][/color]
> a[color=green][color=darkred]
>> >> System.Web.UI.WebControls.GridView control on your page, when the page[/color][/color]
> is[color=green][color=darkred]
>> >> rendered, the System.Web.UI.WebControls.GridView control emits HTML[/color][/color]
> that[color=green][color=darkred]
>> > is
>> >> XHTML compliant. All generated elements use explicit opening and[/color][/color]
> closing[color=green][color=darkred]
>> >> tags (or self-closing tags), and attribute values are included in[/color][/color]
> double[color=green][color=darkred]
>> >> quotation marks.
>> >>
>> >> c.. Formatting information is rendered using only cascading style[/color][/color]
> sheet[color=green][color=darkred]
>> >> styler. To support this standard, ASP.NET controls do not render
>> >> <font>
>> > tags
>> >> or attributes such as bgcolor.
>> >>
>> >> d.. Controls do not render custom attributes (expando attributes)[/color][/color]
> that[color=green][color=darkred]
>> > are
>> >> not defined in the XHTML standards.
>> >>
>> >> e.. In ASP.NET, if controls generate IDs, as occurs in the Repeater,
>> >> GridView, and other controls, the format of the IDs is XHTML 1.1
>> > compliant.
>> >>
>> >> f.. ASP.NET dynamically adds an action attribute to the form tag.
>> > Because
>> >> XHTML 1.1 prohibits it, form tags do not include a name attribute.
>> >>
>> >> g.. Because XHTML requires all elements to be enclosed in a
>> >> container
>> >> element, ASP.NET controls such as input elements are rendered in div
>> >> elements. This includes the HTML markup rendered for controls such as[/color][/color]
> the[color=green][color=darkred]
>> >> TextBox, CheckBox, and RadioButton controls. It also includes hidden
>> > fields,
>> >> such as the element used to store view-state data.
>> >>
>> >> h.. ASP.NET codes characters such as & (for example, as &). This
>> >> includes URLs that are generated to reference JavaScript script and
>> >> the
>> >> contents of encoded values such as view state.
>> >>
>> >> i.. Any script tags rendered into the page include an appropriate[/color][/color]
> type[color=green][color=darkred]
>> >> attribute. (This pertains to scripts that are created by the page or
>> >> controls or by the RegisterHiddenField, RegisterStartupScript, and
>> >> RegisterClientScriptBlock methods; script blocks that you create are[/color][/color]
> not[color=green][color=darkred]
>> >> automatically amended with a type attribute.) In ASP.NET any script[/color][/color]
> tags[color=green][color=darkred]
>> >> rendered by the page use the appropriate type attribute
>> >> (type="type/javascript") and do not include a language attribute.[/color][/color]
> ASP.NET[color=green][color=darkred]
>> >> renders script tags when the page includes certain controls (such as[/color][/color]
> the[color=green][color=darkred]
>> >> System.Web.UI.WebControls.HyperLink ,
>> >> System.Web.UI.WebControls.LinkButton
>> > ,
>> >> and System.Web.UI.WebControls.Calendar controls) that require client
>> > script
>> >> to perform a postback. Script is also rendered for controls that rely[/color][/color]
> on[color=green][color=darkred]
>> >> client-side functionality, such as the[/color][/color]
> System.Web.UI.WebControls.TreeView[color=green][color=darkred]
>> >> and validator controls.
>> >>
>> >> j.. IF ASP.NET renders script blocks, the contents of the script[/color][/color]
> blocks[color=green][color=darkred]
>> > is
>> >> rendered in CDATA elements (inside <![CDATA[ and ]]> tags) to prevent
>> >> special characters such as & and < from being interpreted as XML.
>> >>
>> >> Controlling XHTML Rendering of ASP.NET Page and Controls
>> >> Under some circumstances, you might not want ASP.NET controls to
>> >> render
>> >> XHTML 1.1 markup. For example, XHTML 1.1 standards prohibit the use of[/color][/color]
> a[color=green][color=darkred]
>> >> name attribute in an HTML form tag, so ASP.NET does not render that
>> >> attribute. However, in your application, you might have existing pages
>> > with
>> >> client script that relies on the form tag's name attribute.
>> >>
>> >> You can configure ASP.NET so that it does not render XHTML 1.1 markup[/color][/color]
> to[color=green][color=darkred]
>> >> allow pages created in earlier versions of ASP.NET to work as
>> >> designed.
>> > For
>> >> more information, see How to: Configure ASP.NET for Non-XHTML[/color][/color]
> Rendering.[color=green][color=darkred]
>> >>
>> >>
>> >>
>> >> "Patrice" <nobody@nowhere.com> wrote in message
>> >> news:e56AGhfYFHA.2124@TK2MSFTNGP14.phx.gbl...
>> >> > As noted by Joerg, this is HTML not XHTML...
>> >> >
>> >> > If it really causes a problem you could register the client script
>> >> > using
>> >> > the
>> >> > "ClientScript" member of the page class and just make the call using
>> >> > Attributes.Add. Here you render the script as an HTML attribute[/color][/color]
> causing[color=green][color=darkred]
>> >> > the
>> >> > string to be HTML encoded (likely ASP.NET doesn't check anyhting,[/color][/color]
> this[color=green][color=darkred]
>> > is
>> >> > an
>> >> > HTML attribute then it encodes it)...
>> >> >
>> >> > Let us know about your findings (especially if using HTML encoded
>> > scripts
>> >> > causes a problem on some browsers)...
>> >> >
>> >> > Patrice
>> >> >
>> >> > --
>> >> >
>> >> > "Alex D." <alexware69@hotmail.com> a écrit dans le message de
>> >> > news:OJnkyJfYFHA.3712@TK2MSFTNGP09.phx.gbl...
>> >> >> like this:
>> >> >>
>> >> >> this.txtUserName.Attributes.Add("onkeydown","if((e vent.which &&
>> >> > event.which
>> >> >> == 13)||(event.keyCode && event.keyCode ==
>> >> >> 13)){document.Form1.cmdLogin.click();return false;}else return
>> >> >> true;");
>> >> >>
>> >> >> that code rendered javascript to the client OK. Now that I upgraded[/color][/color]
> to[color=green][color=darkred]
>> >> >> ASP.NET 2 Beta 2 it is rendering && instead of &&, so[/color][/color]
> clients[color=green][color=darkred]
>> > are
>> >> >> getting this instead:
>> >> >>
>> >> >> if((event.which && event.which == 13)||(event.keyCode
>> > &&
>> >> >> event.keyCode == 13)){document.Form1.cmdLogin.click();return
>> > false;}else
>> >> >> return true;
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> "Patrice" <nobody@nowhere.com> wrote in message
>> >> >> news:uLla7GfYFHA.3132@TK2MSFTNGP09.phx.gbl...
>> >> >> > How do you render your scripts ?
>> >> >> >
>> >> >> > Patrice
>> >> >> >
>> >> >> > --
>> >> >> >
>> >> >> > "Alex D." <alexware69@hotmail.com> a écrit dans le message de
>> >> >> > news:uqiPWBfYFHA.2956@TK2MSFTNGP10.phx.gbl...
>> >> >> >> How can I stop asp.net from rendering XHTML istead of HTML?
>> >> >> >> My javascripts are rendering wrong because of that. It is[/color][/color]
> rendering[color=green][color=darkred]
>> >> > &
>> >> >> > to
>> >> >> >> clients instead of &.
>> >> >> >> Any help?
>> >> >> >> Thanks,
>> >> >> >> Alejandro.
>> >> >> >>
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >[/color]
>>
>>[/color]
>
>[/color]