[英]How can I use vb.net in javascript
I have question about use vb.net in javascript. 我对在javascript中使用vb.net有疑问。
<script runat="server">
Dim x As String
Function Addx(ByVal txt As String) As String
x = txt
Return x
End Function
</script>
I use function "Addx" in javascript like this. 我在javascript中使用函数“ Addx”,就像这样。
<script language="javascript" type="text/javascript>
var Getx = "<%=Addx('Hello World') %>";
alert(Getx);
</script>
But it does not work and has an error. 但是它不起作用并且有错误。
Argument not specified for parameter 'txt' of 'Public Function Addx(txt As String) As String
What can I do? 我能做什么?
VB doesn't allow single quotes for strings. VB不允许字符串使用单引号。 JavaScript does.
JavaScript可以。 So, switch them around, and it should work.
因此,切换它们,它应该可以工作。
<script language="javascript" type="text/javascript">
var Getx = '<%=Addx("Hello World") %>';
alert(Getx);
</script>
Edit: Also, make sure to close your quotes in your script tag attributes. 编辑:此外,请确保关闭脚本标记属性中的引号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.