what is the purpose of command name and command argument for a control example button?

后端 未结 7 1464
孤街浪徒
孤街浪徒 2021-02-07 09:57

what is the purpose of command name and command argument for a control example button? when should we go for this?

相关标签:
7条回答
  • 2021-02-07 10:46

    CommandName:

    When you have multiple Button controls on a Web page, use the CommandName property to specify or determine the command name associated with each Button control. You can set the CommandName property with any string that identifies the command to perform. You can then programmatically determine the command name of the Button control and perform the appropriate actions.

    (My emphasis)

    CommandArgument:

    An optional parameter passed to the Command event along with the associated CommandName.

    ...which you retrieve from the event object (for instance, e) as e.CommandArgument.

    So for instance, you might have four buttons with the CommandName "DoSomething" but four different CommandArguments telling your "DoSomething" code what to do, or what to do it to. You might also have other buttons with CommandName = "DoSomethingElse" that, well, do something else. :-)

    0 讨论(0)
提交回复
热议问题