简体   繁体   中英

Calling a function through buttons in ASP.NET using VB

I'm having some issues with calling the function I have defined when I click a button. For example, my function is something like this:

<script runat = "server" language = "vb">

Sub deleteFunction()
    Response.Write("hello test test")
End Sub

</script>

This is all within the <head> tags. In the <body> tags, I have this:

<form method = "post" action = "HubPage.aspx">
    <input type = "submit" value = "Delete" onclick = "<% deleteFunction() %>">
</form>

That doesn't work because it just calls the function without me ever having to click the button. So I tried this:

<form method = "post" action = "HubPage.aspx" onsubmit = "<% deleteFunction() %>">
    <input type = "submit" value = "Delete">
</form>

However, that also calls the function regardless.

Can anyone point me in the right direction?

您可以删除onclick事件,但这可以在您的.Net代码中调用javascript代码

Page.ClientScript.RegisterStartupScript(Me.GetType, Nothing, "FunctionName();", True)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM