Using htc file in assemble include resource

  • Thread starter Thread starter Pab
  • Start date Start date
P

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
 
Pab said:
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.
 
Using text/x-component instead of text/javascript decided a point.
Great! Thanks!


Anthony Jones said:
Pab said:
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.
 
Back
Top