admin管理员组文章数量:1208155
I have written VB.NET code for calling my Javascript function showDisplay()
.
vb code:
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "Script", "showDisplay();", True)
javascript code:
function showDisplay(){
alert('success');}
but this is not working, can you help?
I have written VB.NET code for calling my Javascript function showDisplay()
.
vb.net code:
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "Script", "showDisplay();", True)
javascript code:
function showDisplay(){
alert('success');}
but this is not working, can you help?
Share Improve this question edited Jan 20, 2014 at 5:50 Nalaka526 11.5k21 gold badges84 silver badges118 bronze badges asked Jan 20, 2014 at 5:47 NovusNovus 1011 gold badge2 silver badges9 bronze badges 1- possible duplicate of How to call javascript function from code-behind – The Hungry Dictator Commented Jan 20, 2014 at 5:52
1 Answer
Reset to default 15Perhaps you are looking for RegisterStartupScript:
ScriptManager.RegisterStartupScript(Me, Page.GetType, "Script", "showDisplay();", True)
Depending on where your showDisplay()
javascript function exists in your code, using RegisterClientScriptBlock
may not find it. This is because RegisterClientScriptBlock
places the javascript at the top of your page, immediately after the viewstate. Using RegisterStartupScript
will place the call to showDisplay()
at the very bottom of your form, so it will be rendered last and your javascript function will have already been rendered and available.
本文标签: how to call javascript function from vbnet codeStack Overflow
版权声明:本文标题:how to call javascript function from vb.net code? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738753976a2110563.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论