在我的服务器端代码中,我需要显示警告消息,并在满足某个条件时停止执行页面。执行停止,但我没有收到警报消息。我错过了什么?我的代码是这样的。
Try
If txtAmtRequested.Text > Val(HiddenTotalFeeAmount.Value) Then
ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), UniqueID,
"javascript:alert('Total Fee Amount set for this student is - '" & HiddenTotalFeeAmount.Value & "'... Enter Concession Amount lesser than this one..!')", True)
Exit Function
End If
Catch ex As Exception
End Try
答案 0 :(得分:3)
试试这个:
Try
If txtAmtRequested.Text > Val(HiddenTotalFeeAmount.Value) Then
ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), UniqueID,
"javascript:alert('Total Fee Amount set for this student is - " & HiddenTotalFeeAmount.Value & "... Enter Concession Amount lesser than the..!');", True)
Exit Function
End If
Catch ex As Exception
End Try
在插入您的值时,您在javascript中结束了字符串,从而产生了这个javascript:
javascript:alert('Total Fee Amount set for this student is - ' <Value> '... Enter Concession Amount lesser than the..!');
而不是这个,你必须直接将值插入字符串,或添加“+”来连接字符串:
javascript:alert('Total Fee Amount set for this student is - <Value> ... Enter Concession Amount lesser than the..!');
或
javascript:alert('Total Fee Amount set for this student is - ' + <Value> + '... Enter Concession Amount lesser than the..!');