在java脚本函数之前执行函数背后的VB代码 [英] execute VB code behind function before java script function

查看:29
本文介绍了在java脚本函数之前执行函数背后的VB代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<块引用>

可能的重复:
从javascript调用ASP函数

可以运行此代码:

 <身体><form id="form1" runat="server"><div><asp:Button ID="buttonme" runat="server" OnClientClick="javascript:hello()" Text="click"/>

背后的代码:

 Protected Sub buttonme_Click(ByVal senderAs Object, ByVal e As EventArgs) 处理 buttonme.ClickMsgBox("来自 vb.net 的你好世界")结束子

会在 vb.net MsgBox 之前执行 javascript 消息吗?有没有办法让这个翻转来执行javascript函数第二谢谢

解决方案

简短的回答是否定的.VB 代码是服务器端.javascript 代码在客户端.有多种方法可以从 javascript(例如 Ajax)执行服务器端代码.

此外,您不希望在 Web 服务器上调用 MessageBox.Show,因为那里应该没有 UI,它会阻止执行.

Possible Duplicate:
calling ASP function from javascript

okay running this code :

     <script type="text/javascript">
    function hello() { 
        alert("hello world from javascript ")
    }
 </script>
  </head>
 <body>
<form id="form1" runat="server">
<div>
    <asp:Button ID="buttonme" runat="server" OnClientClick="javascript:hello()" Text="click" />
</div>

CODE BEHIND :

  Protected Sub buttonme_Click(ByVal sender 
As Object, ByVal e As EventArgs) Handles buttonme.Click
    MsgBox("hello world from vb.net ")
End Sub

will execute the javascript message before the vb.net MsgBox ? is there is a way to make this flipped to execute the javascript function second THANKS

解决方案

The short answer is no. The VB code is server side. The javascript code is on the client side. There are ways to execute server side code from javascript (e.g. Ajax).

Also, you don't want to call MessageBox.Show on the web server as there should be no UI there and it will block execution.

这篇关于在java脚本函数之前执行函数背后的VB代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆