在我的服務器端頁面上,我有一段遺留腳本,我想修改它以測試在打開確認窗口之前字段是否爲空。這是我嘗試添加$(#hdfldRecId),因爲如果此字段爲空,我不希望打開確認。確認腳本中的Java腳本IIF
scriptBlock = "function beforeDelete()" & vbCrLf & _
"{return($('#hdfldRecId').val() !> '' && confirm('Are you sure you want to delete this item?'));}"
If (Not ClientScript.IsClientScriptBlockRegistered("deletePromptScript")) Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), _
"deletePromptScript", _
scriptBlock, _
True)
End If
'use the OnClientClick property of the button to cause the above
'script to be executed when the button is clicked
btndelete.OnClientClick = "return(beforeDelete());"
當我執行頁面時,調試表明()缺少,但配對都匹配。
<script type="text/javascript">
//<![CDATA[
function beforeDelete()
{return($('#hdfldRecId').val() !> '' && confirm('Are you sure you want to delete this item?'));}//]]>
</script>
所以我不知道我怎麼添加這個測試,看看是否有在$(hdfldRecId)的值,如果有則執行確認對話框。
謝謝
返回不是一個方法,所以擺脫(和)。 ''return beforeDelete();「' – epascarello 2014-09-05 15:22:19
什麼是'!>' – epascarello 2014-09-05 15:23:06
我在」vbCrLf&「之後看到了一些」_「這是什麼? – patricK 2014-09-05 15:27:42