开发者

Running Javascript to size an ASP.NET control once it is rendered or updated by a postback

开发者 https://www.devze.com 2023-03-15 01:55 出处:网络
I have an ascx control tha开发者_JS百科t is loaded in an aspx page. How can I instruct my ascx to run javascript once it is rendered in the browser.

I have an ascx control tha开发者_JS百科t is loaded in an aspx page. How can I instruct my ascx to run javascript once it is rendered in the browser. It should run on every postback as well.

I looked around but could not find a satisfactory answer.


Have you tried using the "RegisterStartupScript" method along with JQuery to call a JS function? This code might help you:

ScriptManager.RegisterStartupScript(Page, GetType(Page), "myScript", "$(function() {{ alert ('Your page is loaded.'); }});", True)

You can replace the alert with any JS function you want :)

I hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消