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?
当您将用户控件设置为visible="false"
,该控件的内容将不会呈现,而是使用style="display:none"
隐藏该控件,使其呈现控件的内容。
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.