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

后端 未结 7 1629
孤街浪徒
孤街浪徒 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:33

    The Command event makes it easy to write a single method that handles the clicks of multiple buttons.

    protected void Button_Command(object sender, CommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "Back":
                FeedbackLabel.Text = "Back";
                break;
            case "Up":
                FeedbackLabel.Text = "Up";
                break;
            case "Forward":
                FeedbackLabel.Text = "Forward";
                break;
        }
    }
    

提交回复
热议问题