I have developed a simple datatype consisting of a div that contains a list of images.The method I have used was to create a control that inherits IUsercontrolDataEditor. I now want to include some CSS to style these elements.
The project name is UmbracoDatatypes, and DataTypes.css is held in the Styles folder. I have made sure that the build option is set to EmbeddedResource.
However, after copying over the dll and ascx files to the umbraco folder and adding the data type, the css is not applied. Is there something I have missed?
Hi Jeroen, Thanks for pointing that out. Taking a look in the source code of uComponents was a great help. After a bit of a struggle I now have the resources being included using the following code:
protected override void OnInit(EventArgs e) { base.OnInit(e); var resourceUrl = Page.ClientScript.GetWebResourceUrl(typeof(Uploader), "UmbracoDataTypes.Styles.DataTypes.css"); var target = Page.Header;
target.Controls.Add(new LiteralControl( "") ); }
Edit: I'll mark this reply as the solution as it contains the code that I used in order to get round the initial problem. But thanks for pointing me in the right direction Jeroen!
Custom Datatype CSS
Hello!
I have developed a simple datatype consisting of a div that contains a list of images.The method I have used was to create a control that inherits IUsercontrolDataEditor. I now want to include some CSS to style these elements.
I have added the following to the code behind:
The project name is UmbracoDatatypes, and DataTypes.css is held in the Styles folder. I have made sure that the build option is set to EmbeddedResource.
I then run the following code OnInit():
However, after copying over the dll and ascx files to the umbraco folder and adding the data type, the css is not applied. Is there something I have missed?
I don't have any experience with this, but have a look at the source of uComponents. http://ucomponents.codeplex.com/SourceControl/list/changesets. They do the same thing.
Jeroen
Hi Jeroen,
Thanks for pointing that out. Taking a look in the source code of uComponents was a great help.
After a bit of a struggle I now have the resources being included using the following code:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
var resourceUrl = Page.ClientScript.GetWebResourceUrl(typeof(Uploader), "UmbracoDataTypes.Styles.DataTypes.css");
var target = Page.Header;
target.Controls.Add(new LiteralControl(
"")
);
}
Edit: I'll mark this reply as the solution as it contains the code that I used in order to get round the initial problem. But thanks for pointing me in the right direction Jeroen!
is working on a reply...