PDA

View Full Version : [CLOSED] Custom Controls & resources. Creating at client side.



alex303
Dec 23, 2015, 9:03 AM
Hi,
I created a lot of my own controls, inherited from various Ext.Net controls...
Most of those controls use js/css resources, registered by overriding List<ResourceItem> Resources { get; }.
All works fine while I create my controls via builders in *.cshtml.

The problem comes then I try create my control dynamically at client side - no embedded resources registered. So JS-code ext.Create('MyOwnControl') fail.

Is the any correct way to register control resources without creating an instance of control at server side?

It would be nice to have a method like this:
@ext.ResourceManager().RequiredControl(typeof(MyOw nControl))

Any suggestion are welcome)

Daniil
Dec 23, 2015, 6:48 PM
Hi @alex303,

Please use ResourceManager.RegisterControlResources<MyControl>();.

Here is a full example with a SelectBox which has an individual JavaScript file since it is an UX. Please notice that a call should be after the ResourceManager definition.


<!DOCTYPE html>
<html>
<head>
<title>Ext.Net.MVC v2 Example</title>
</head>
<body>
@Html.X().ResourceManager()

@{
ResourceManager.RegisterControlResources<SelectBox>();
}
</body>
</html>

alex303
Dec 23, 2015, 7:41 PM
My bad... I was looking for such method in sources attentively, and didnt find it.
Anyway thanks a lot, Daniil!