Using htc file in assemble include resource

Using htc file in assemble include resource

am 17.04.2008 10:28:00 von Pab

I am developing the web controls and try to include all client files:
scripts, styles, etc in an assembly as resource common way like:
[assembly: System.Web.UI.WebResource("TLF.behaviour.htc",
"text/javascript")], and use ClientScriptManager class.

I have faced a problem with htc files, I get url following way:

class MyControl:WebControl
{
string GetUlr()
{
return this.Page. ClientScript.
GetWebResourceUrl(this.GetType(),”TLF.behaviour.htc”);
}
}
The method returns some like
“WebResource.axd?d=sVNSkov2zl0&t=633439341206302606” correctly.

But in run time no behavoior has been load – seems IE needs “.htc” file
extantion to attach behavoior. ?

Any suggestions?
Thanks

Re: Using htc file in assemble include resource

am 17.04.2008 11:34:36 von Anthony Jones

"Pab" wrote in message
news:9B13ECDD-3B3B-4583-BC1C-D69F79183782@microsoft.com...
> I am developing the web controls and try to include all client files:
> scripts, styles, etc in an assembly as resource common way like:
> [assembly: System.Web.UI.WebResource("TLF.behaviour.htc",
> "text/javascript")], and use ClientScriptManager class.
>
> I have faced a problem with htc files, I get url following way:
>
> class MyControl:WebControl
> {
> string GetUlr()
> {
> return this.Page. ClientScript.
> GetWebResourceUrl(this.GetType(),"TLF.behaviour.htc");
> }
> }
> The method returns some like
> "WebResource.axd?d=sVNSkov2zl0&t=633439341206302606" correctly.
>
> But in run time no behavoior has been load - seems IE needs ".htc" file
> extantion to attach behavoior. ?
>

A HTC is not Javascript, try using text/x-component instead of
text/javascript.

If that doesn't work then you might be right about it needing HTC extension.
behaviours in IE are an old technology.

Personally I would avoid them. .NET gives you alternatives for example if
you are adding a behaviour to an INPUT you can inherit the server side
representation and include some code to hook up the events you need and
inject what Javascript is needed.


--
Anthony Jones - MVP ASP/ASP.NET

Re: Using htc file in assemble include resource

am 17.04.2008 14:24:01 von Pab

Using text/x-component instead of text/javascript decided a point.
Great! Thanks!


"Anthony Jones" wrote:

> "Pab" wrote in message
> news:9B13ECDD-3B3B-4583-BC1C-D69F79183782@microsoft.com...
> > I am developing the web controls and try to include all client files:
> > scripts, styles, etc in an assembly as resource common way like:
> > [assembly: System.Web.UI.WebResource("TLF.behaviour.htc",
> > "text/javascript")], and use ClientScriptManager class.
> >
> > I have faced a problem with htc files, I get url following way:
> >
> > class MyControl:WebControl
> > {
> > string GetUlr()
> > {
> > return this.Page. ClientScript.
> > GetWebResourceUrl(this.GetType(),"TLF.behaviour.htc");
> > }
> > }
> > The method returns some like
> > "WebResource.axd?d=sVNSkov2zl0&t=633439341206302606" correctly.
> >
> > But in run time no behavoior has been load - seems IE needs ".htc" file
> > extantion to attach behavoior. ?
> >
>
> A HTC is not Javascript, try using text/x-component instead of
> text/javascript.
>
> If that doesn't work then you might be right about it needing HTC extension.
> behaviours in IE are an old technology.
>
> Personally I would avoid them. .NET gives you alternatives for example if
> you are adding a behaviour to an INPUT you can inherit the server side
> representation and include some code to hook up the events you need and
> inject what Javascript is needed.
>
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>
>