これは私のForm1.cs
ファイルです。このメソッドは、MessageBox
によってクリックされたボタンのIDを表示する必要がありますが、このエラーが発生します。ボタンにIDの定義がありません
private void button_Click(object sender, EventArgs e)
{
Button button = sender as Button;
string buttonId = button.ID;
MessageBox.Show(buttonId);
}
エラー:
'Button' does not contain a definition for 'ID' and no extension method 'ID' accepting a first argument of type 'Button' could be found (are you missing a using directive or an assembly reference?)
このASP.NET WebサイトまたはWindowsアプリケーションのですか? – Nirman
正しい名前空間を使用しましたか? – Prabu
これはWindowsアプリケーションです。 – Alex