Using htc file in assemble include resource

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
 
A

Anthony Jones

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.
 
P

Pab

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top