<tfoot id='OQl4o'></tfoot>
      • <bdo id='OQl4o'></bdo><ul id='OQl4o'></ul>

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

      <legend id='OQl4o'><style id='OQl4o'><dir id='OQl4o'><q id='OQl4o'></q></dir></style></legend>

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

      C#:调用按钮事件处理程序方法而不实际单击按钮

      C#: calling a button event handler method without actually clicking the button(C#:调用按钮事件处理程序方法而不实际单击按钮)
            <tbody id='I129p'></tbody>
            <bdo id='I129p'></bdo><ul id='I129p'></ul>
              <tfoot id='I129p'></tfoot>
              <i id='I129p'><tr id='I129p'><dt id='I129p'><q id='I129p'><span id='I129p'><b id='I129p'><form id='I129p'><ins id='I129p'></ins><ul id='I129p'></ul><sub id='I129p'></sub></form><legend id='I129p'></legend><bdo id='I129p'><pre id='I129p'><center id='I129p'></center></pre></bdo></b><th id='I129p'></th></span></q></dt></tr></i><div id='I129p'><tfoot id='I129p'></tfoot><dl id='I129p'><fieldset id='I129p'></fieldset></dl></div>

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

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

              2. 本文介绍了C#:调用按钮事件处理程序方法而不实际单击按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我的 aspx 文件中有一个名为 btnTest 的按钮..cs 文件有一个在单击按钮时调用的函数.

                I have a button in my aspx file called btnTest. The .cs file has a function which is called when the button is clicked.

                btnTest_Click(object sender, EventArgs e)
                

                如何在我的代码中调用此函数(即不实际单击按钮)?

                How can I call this function from within my code (i.e. without actually clicking the button)?

                推荐答案

                btnTest_Click(null, null);
                

                前提是该方法没有使用这些参数中的任何一个(通常不使用.)

                Provided that the method isn't using either of these parameters (it's very common not to.)

                说实话,虽然这很恶心.如果您有需要调用的代码,则应遵循以下约定:

                To be honest though this is icky. If you have code that needs to be called you should follow the following convention:

                protected void btnTest_Click(object sender, EventArgs e)
                {
                   SomeSub();
                }
                
                protected void SomeOtherFunctionThatNeedsToCallTheCode()
                {
                   SomeSub();
                }
                
                protected void SomeSub()
                {
                   // ...
                }
                

                这篇关于C#:调用按钮事件处理程序方法而不实际单击按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                C# namespace alias - what#39;s the point?(C# 命名空间别名 - 有什么意义?)
                Using Xpath With Default Namespace in C#(在 C# 中使用具有默认命名空间的 Xpath)
                Generating an EDMX from a DB2 Database(从 DB2 数据库生成 EDMX)
                Using entity Framework with .NET Core and DB2(将实体框架与 .NET Core 和 DB2 结合使用)
                IBM .NET Data Provider Connection String issue with Library List(库列表的 IBM .NET 数据提供程序连接字符串问题)
                .NET DB2 OLEDB pre-requisites(.NET DB2 OLEDB 先决条件)
                <i id='Hi6YK'><tr id='Hi6YK'><dt id='Hi6YK'><q id='Hi6YK'><span id='Hi6YK'><b id='Hi6YK'><form id='Hi6YK'><ins id='Hi6YK'></ins><ul id='Hi6YK'></ul><sub id='Hi6YK'></sub></form><legend id='Hi6YK'></legend><bdo id='Hi6YK'><pre id='Hi6YK'><center id='Hi6YK'></center></pre></bdo></b><th id='Hi6YK'></th></span></q></dt></tr></i><div id='Hi6YK'><tfoot id='Hi6YK'></tfoot><dl id='Hi6YK'><fieldset id='Hi6YK'></fieldset></dl></div>
                <legend id='Hi6YK'><style id='Hi6YK'><dir id='Hi6YK'><q id='Hi6YK'></q></dir></style></legend>
                    <bdo id='Hi6YK'></bdo><ul id='Hi6YK'></ul>
                      <tfoot id='Hi6YK'></tfoot>

                      1. <small id='Hi6YK'></small><noframes id='Hi6YK'>

                            <tbody id='Hi6YK'></tbody>