ASP.NET用户控件+ Javascript

I have an usercontrol with javascript inside. I'm using it into a page with ASP.NET Ajax enabled. It works fine in most scenarios, but when the instance of the usercontrol is not visible in the first request and I make visible through an Ajax postback the javascript is not executed. Any help?

when you set user control visible="false" the content of that control will not render instead use style="display:none" to hide the control that way the content of the control will render.

When using Control1.Visible = false; your control will not render on your page at all.

The async postback you are using does not re-render the entire page. If your control was injecting javascript to the page this javascript will not render.

A quick and dirty work around for your control is to use.

Control1.Attributes.Add("style", "display:none;") to hide Control1.Attributes.Add("style", "display:block;") to show