首页 > 解决方案 > 单击时asp LinkBut​​ton不会产生代码

问题描述

我目前正在使用 Visual Studio 2019,我正在使用 asp 链接按钮,当您通常双击 onclick VS 将打开已定义事件的 .cs 页面。我无法做到这一点,有人遇到过这个问题吗?

<asp:LinkButton class="ftr" ID="LoginBtn" runat="server" onClick ="LoginBtn" Visible="True">Login</asp:LinkButton> &nbsp;

标签: asp.net

解决方案


动态控件在双击时停止在 .cs 文件中生成事件的原因有很多。主要之一是请查看您的页面指令正确指向CodeBehind文件及其继承位置。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="projectname.index" %>

在上面的代码中index是页面名称,index.aspx.cs是代码隐藏文件,所以我的 cs 文件看起来像:

namespace projectname
{
public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
 }
}

推荐阅读