すべてのテキストボックスの合計を別のテキストボックスに表示する必要があります。これはサーバー側で実行されます。
テキストボックスの値は、任意の整数またはnull値です。
テキストボックスの「autopostback」プロパティをtrueに設定しました。
private void TextBox2_TextChanged(object sender, EventArgs e)
{
if ((!string.IsNullOrEmpty(TextBox2.Text)) && (!string.IsNullOrEmpty(TextBox3.Text)))
{
TextBox8.Text = (Convert.ToInt32(TextBox2.Text) + Convert.ToInt32(TextBox3.Text)).ToString();
}
}
これをcsファイルに追加した後、ページを実行しようとしましたが、このコンパイラエラーが表示されました
'WebApplication1.c_fail.TextBox2_TextChanged(object, System.EventArgs)' is inaccessible due to its protection level
<asp:TextBox ID="TextBox2" runat="server" AutoPostBack="True"
ontextchanged="TextBox2_TextChanged"></asp:TextBox>
誰かがこのエラーの解決策を提供できる場合、または状況を解決するための正しいコードを提供できる場合。提供するコードは、テキストボックスにnull値がある場合にも機能するはずです。