PDA

View Full Version : [CLOSED] Use UI themes in javascript



jchau
Nov 16, 2015, 8:51 PM
How can I embed the necessary UI css files if the button I want to set ui: 'success' is created in javascript?

Daniil
Nov 17, 2015, 11:00 AM
Hi @jchau,

I am not 100% sure I've got the question correctly, but:

Example

<%@ Page Language="C#" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
string theme = X.ResourceManager.Theme.ToString().ToLowerInvarian t();
string ui = "-success";
string rtl = X.ResourceManager.RTL ? "-rtl" : "";
string pathEmbedded = string.Format("Ext.Net.Build.Ext.Net.uipack.{0}.ext-net-ui{1}{2}-embedded.css", theme, ui, rtl);

X.ResourceManager.RegisterClientStyleInclude(pathE mbedded);
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
Ext.onReady(function () {
Ext.create("Ext.button.Button", {
renderTo: Ext.getBody(),
ui: "success",
text: "Button"
});
});
</script>
</head>
<body>
<ext:ResourceManager runat="server" />

</body>
</html>


I took the registration CSS code from the AbstractComponent's RegisterUIResources.