我是ASPX和VB.net的新手,所以我试图从我的aspx页面实现简单的onClick方法以打开一个新的onClick方法,但是出现以下错误:
Button不是asp.net的成员。
这是我带有引导程序的简单html页面:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="login.aspx.vb" Inherits="gabServizi.login" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<link rel="icon" href="/img/favicon.ico">
<title>Gab Servizi: Login</title>
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<link href="style/login.css" type="text/css" rel="stylesheet" />
</head>
<body class="text-center">
<form class="form-signin fade-in">
<img class="mb-2 " src="/img/gabservizi.png" alt="" width="160" height="160">
<h1 class="h3 mb-3 font-weight-normal" translate="yes">Accedi a Gab Servizi!</h1>
<label for="inputEmail" class="sr-only">Email</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email..." required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password..." required>
<div class="custom-control custom-checkbox mb-3">
<input type="checkbox" class="custom-control-input" id="ricordaCheck">
<label class="custom-control-label" for="ricordaCheck">Ricordami</label>
</div>
<asp:Button class="btn btn-lg btn-primary btn-block" ID="Button1" runat="server" Text="Accedi" onClick="Button1_Click" />
<p class="text-muted mt-2 mb-3">Non hai un account? <a href="register.aspx" class="text-primary"> Registrati!</a></p>
<p class="mt-4 mb-3 text-muted">GAB Tamagnini © 2014 Via Beniamino Disraeli, 17, 42124 Reggio Emilia</p>
</form>
</body>
</html>
这是vb部分:
Public Class login
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Response.Redirect("index.aspx")
End Sub
End Class
答案 0 :(得分:1)
嗨,请尝试使用服务器端方法
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Server.Transfer("index.aspx", True)
End Sub