PDA

View Full Version : [CLOSED] Add Js To DynamicUserControl



vzx
Aug 13, 2013, 10:03 AM
Hi,

I want to add some JS code to ascx referencing to this example (http://examples2.ext.net/#/Loaders/Component/Direct_Method/). Actually, first i had tried to load a store but i couldn't do that on BeforeRender. Then i try to add JS, but again ResourceManager.GetInstance(this.Page) is null on BeforeRender. Could you show me a way to do this?

Thanks,

Vzx

Daniil
Aug 13, 2013, 12:54 PM
Hi @vzx,

This appears to be working for the example you mentioned.

public void BeforeRender()
{
this.Controls.Add(new Ext.Net.Panel { Title = "Item 1" });
this.Controls.Add(new Ext.Net.Panel { Title = "Item 2" });
this.Controls.Add(new Ext.Net.Panel { Title = "Item 3" });

X.Js.AddScript("alert('Hello from BeforeRender!');");
}

Though it will probably work only if use a Loader's DirectMethod.

In other case, you could try to put a required script into HtmlBin of Ext.NET container.

vzx
Aug 13, 2013, 1:16 PM
Hi @vzx,

This appears to be working for the example you mentioned.

public void BeforeRender()
{
this.Controls.Add(new Ext.Net.Panel { Title = "Item 1" });
this.Controls.Add(new Ext.Net.Panel { Title = "Item 2" });
this.Controls.Add(new Ext.Net.Panel { Title = "Item 3" });

X.Js.AddScript("alert('Hello from BeforeRender!');");
}

Though it will probably work only if use a Loader's DirectMethod.

In other case, you could try to put a required script into HtmlBin of Ext.NET container.

Oops, sorry Daniil. It was my fault. You can close this thread.