这是一个回发问题(我不想使用客户端来解决这个问题,必须有一种方法来防止回发然后使用客户端),我有一个按钮,点击它会调用一个javascript函数后面的代码,但在此之前它回发页面,问题是:我如何跳过回发步骤并跳转到 javascript 部分?
<script type="text/javascript">
function hello(name) {
alert("hello world from javascript " + name)
return false;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
后面的代码:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim Myname As String = "myName"
Dim cstype As Type = Me.GetType()
Page.ClientScript.RegisterStartupScript(cstype, "MyKey", "hello('" & Myname & "');", True)
End Sub