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

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

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

    1. 从函数调用按钮 OnClick

      时间:2023-06-05
      <legend id='Hn9Yr'><style id='Hn9Yr'><dir id='Hn9Yr'><q id='Hn9Yr'></q></dir></style></legend>
      <tfoot id='Hn9Yr'></tfoot>

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

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

                本文介绍了从函数调用按钮 OnClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我有一个 OnClick=Button_Click 的按钮.我想从另一个函数调用 Button_Click 但问题是我需要给它:

                I have a button with OnClick=Button_Click. I want to call Button_Click from another function but the problem is that I need to give it:

                (object sender, EventArgs e)
                

                我应该为这些参数输入什么?有什么办法解决吗?

                What should I enter for those parameters? Is there any way around it?

                推荐答案

                你可以这样做

                 Button_Click(null,EventArgs.Empty);
                

                虽然我同意最好提取可以从任何地方调用的函数.

                although I agree that it's better to extract function that could be called from anywhere.

                例如,如果你有

                protected void Button_Click(object sender, EventArgs e)
                {
                  //some list of code      
                }
                

                这段代码应该放在一些新方法中,然后从 Button_Click 或任何其他方法中调用

                this code should be put in some new method and then called from Button_Click or any other method

                private void ExtractedMethod()
                { 
                 //some list of code
                }
                
                 protected void Button_Click(object sender, EventArgs e)
                 {
                  ExtractedMethod();    
                 }
                

                我建议您阅读Martin Fowler 所著的重构:改进现有代码的设计一书.这是架子上的必备品.你会不时回到那本书,它是永恒的.

                I recommend you to read a book Refactoring: Improving the Design of Existing Code by Martin Fowler. It's a must on a shelf. You will come back to that book from time to time, it's timeless.

                这篇关于从函数调用按钮 OnClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:ASP.net C# Gridview ButtonField onclick 事件 下一篇:asp.net listview 在单击时突出显示行

                相关文章

                最新文章

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

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