1. <tfoot id='1c7Tw'></tfoot>

    2. <legend id='1c7Tw'><style id='1c7Tw'><dir id='1c7Tw'><q id='1c7Tw'></q></dir></style></legend>

      <i id='1c7Tw'><tr id='1c7Tw'><dt id='1c7Tw'><q id='1c7Tw'><span id='1c7Tw'><b id='1c7Tw'><form id='1c7Tw'><ins id='1c7Tw'></ins><ul id='1c7Tw'></ul><sub id='1c7Tw'></sub></form><legend id='1c7Tw'></legend><bdo id='1c7Tw'><pre id='1c7Tw'><center id='1c7Tw'></center></pre></bdo></b><th id='1c7Tw'></th></span></q></dt></tr></i><div id='1c7Tw'><tfoot id='1c7Tw'></tfoot><dl id='1c7Tw'><fieldset id='1c7Tw'></fieldset></dl></div>

      <small id='1c7Tw'></small><noframes id='1c7Tw'>

        <bdo id='1c7Tw'></bdo><ul id='1c7Tw'></ul>

      Asp.Net 不包含 buttonClick 的定义?

      时间:2023-06-05
      <legend id='0Lzrd'><style id='0Lzrd'><dir id='0Lzrd'><q id='0Lzrd'></q></dir></style></legend>
        1. <small id='0Lzrd'></small><noframes id='0Lzrd'>

            <i id='0Lzrd'><tr id='0Lzrd'><dt id='0Lzrd'><q id='0Lzrd'><span id='0Lzrd'><b id='0Lzrd'><form id='0Lzrd'><ins id='0Lzrd'></ins><ul id='0Lzrd'></ul><sub id='0Lzrd'></sub></form><legend id='0Lzrd'></legend><bdo id='0Lzrd'><pre id='0Lzrd'><center id='0Lzrd'></center></pre></bdo></b><th id='0Lzrd'></th></span></q></dt></tr></i><div id='0Lzrd'><tfoot id='0Lzrd'></tfoot><dl id='0Lzrd'><fieldset id='0Lzrd'></fieldset></dl></div>
              <tbody id='0Lzrd'></tbody>
            <tfoot id='0Lzrd'></tfoot>
                <bdo id='0Lzrd'></bdo><ul id='0Lzrd'></ul>

                本文介绍了Asp.Net 不包含 buttonClick 的定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我正在尝试在 Visual Studio asp.net 上构建一个程序,但每当我尝试单击带有 OnClick 事件的按钮时,我都会收到以下错误:

                "CS1061: 'ASP.test_aspx' 不包含 'buttonClick' 的定义,并且找不到接受类型为 'ASP.test_aspx' 的第一个参数的扩展方法 'buttonClick'(您是否缺少 using 指令或程序集参考?)"

                这是我的 HTML 供参考:

                <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="MRAApplication.test" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="服务器"><标题></标题></头><身体><form id="form1" runat="server">

                <asp:Button id="b1" Text="Submit" runat="server" OnClick="buttonClick"/><asp:TextBox id="txt1" runat="server"/></div></表格></身体></html>

                这是我的代码:

                使用系统;使用 System.Collections.Generic;使用 System.Linq;使用 System.Web;使用 System.Web.UI;使用 System.Web.UI.WebControls;命名空间 MRAApplication{公共部分类测试:System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){}void buttonClick(对象发送者,EventArgs e){txt1.Text = "文本";}}}

                请保持解释尽可能简单,因为我是编码新手.感谢您的任何帮助.:)

                解决方案

                您需要将您的事件处理程序声明为受保护:

                protected void buttonClick(Object sender, EventArgs e){txt1.Text = "文本";}

                标记本质上是一个继承自后面代码的类.为了使成员可以访问,他们需要受到保护或公开.

                I am attempting to build a program on visual studio asp.net but whenever I try to click a button with an OnClick event I get the following error:

                "CS1061: 'ASP.test_aspx' does not contain a definition for 'buttonClick' and no extension method 'buttonClick' accepting a first argument of type 'ASP.test_aspx' could be found (are you missing a using directive or an assembly reference?)"

                Here is my HTML for reference:

                <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="MRAApplication.test" %>
                
                <!DOCTYPE html>
                
                <html xmlns="http://www.w3.org/1999/xhtml">
                <head runat="server">
                <title></title>
                </head>
                <body>
                <form id="form1" runat="server">
                <div>
                <asp:Button id="b1" Text="Submit" runat="server" OnClick="buttonClick" />
                    <asp:TextBox id="txt1" runat="server" />
                </div>
                </form>
                </body>
                </html>
                

                and here is my code behind:

                using System;
                using System.Collections.Generic;
                using System.Linq;
                using System.Web;
                using System.Web.UI;
                using System.Web.UI.WebControls;
                
                namespace MRAApplication
                {
                public partial class test : System.Web.UI.Page
                {
                
                    protected void Page_Load(object sender, EventArgs e)
                    {
                
                    }
                
                    void buttonClick(Object sender, EventArgs e)
                    {
                        txt1.Text = "Text";
                    }
                }
                }
                

                Please keep explanations as simple as possible as I am new to coding. Thank you for any and all help. :)

                解决方案

                You need to declare your event handler as protected:

                protected void buttonClick(Object sender, EventArgs e)
                {
                    txt1.Text = "Text";
                }
                

                The markup is essentially a class that inherits from the code behind. In order for members to be accessible, they need to be protected or public.

                这篇关于Asp.Net 不包含 buttonClick 的定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:OnClick 与 OnClientClick 的 asp:CheckBox? 下一篇:单击控件内的文本时,用户控件单击事件不起作

                相关文章

                最新文章

                <legend id='TivVZ'><style id='TivVZ'><dir id='TivVZ'><q id='TivVZ'></q></dir></style></legend>
              • <i id='TivVZ'><tr id='TivVZ'><dt id='TivVZ'><q id='TivVZ'><span id='TivVZ'><b id='TivVZ'><form id='TivVZ'><ins id='TivVZ'></ins><ul id='TivVZ'></ul><sub id='TivVZ'></sub></form><legend id='TivVZ'></legend><bdo id='TivVZ'><pre id='TivVZ'><center id='TivVZ'></center></pre></bdo></b><th id='TivVZ'></th></span></q></dt></tr></i><div id='TivVZ'><tfoot id='TivVZ'></tfoot><dl id='TivVZ'><fieldset id='TivVZ'></fieldset></dl></div>

                  <tfoot id='TivVZ'></tfoot>

                  <small id='TivVZ'></small><noframes id='TivVZ'>

                    • <bdo id='TivVZ'></bdo><ul id='TivVZ'></ul>