updatepanel 内にいくつかのテキストボックスがあり、簡単な検証を行っています。検証チェックが失敗すると、エラー メッセージがダイアログ ボックスに表示されます。私の問題は、RegisterClientScriptBlock が、テキスト ボックスの 1 つの検証が失敗したときにダイアログ ボックスを表示するが、他のテキスト ボックスは失敗しないことです。どちらの場合も、イベントが発生しています。以下のコードでは、txtCustMSCName (外側の If ステートメントの Else の下にある 2 番目のテキスト ボックス) テキスト ボックスが検証基準に失敗すると、ダイアログ ボックスは正しく表示されますが、txtMSCName テキスト ボックスが失敗すると表示されません。なぜこれが起こっているのでしょうか?txtMSCName が ReadOnly=True に設定されていることと関係がありますか?
VB:
If chkCustomMSC.Checked = False Then
If txtMSCName.Text = "No sales contact for this account" Then
DialogMsg = "alert('There are no main sales contacts for this account in CRM; please check the 'Custom MSC' box and " _
+ "manually enter the main sales contact information');"
ErrorDialog(DialogMsg)
Exit Sub
End If
Else
If txtCustMSCName.Text = "" Then
DialogMsg = "alert('You must enter a main sales contact name');"
ErrorDialog(DialogMsg)
Exit Sub
End If
End If
Protected Sub ErrorDialog(ByVal Message As String)
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), Message, True)
End Sub
マークアップ:
<asp:TextBox ID="txtMSCName" runat="server" ReadOnly="true" CssClass="DisplayTextBoxStyle"/>
<asp:TextBox ID="txtCustMSCName" runat="server" CssClass="MSCInputTextBoxStyle"/>