从vb.net code后面调用JavaScript [英] Call javascript from vb.net code behind
问题描述
我怎么能说从code javascript函数后面?结果
最流行的回答是 ScriptManager.RegisterStartupScript
,然而,这并不在我的情况下工作。
我有一个做一个数据库检查,看是否有记录存在一个VB类。如果存在,则调用JavaScript函数来显示一个警报(记录存在)
所以我做这样的事情。
暗淡strMessage作为字符串=JavaScript的:RecordExists('参数');
我如何从我的vb.net类的调用这个函数?
如果DataStore.Record.Exists(theRecord)然后 昏暗的脚本作为字符串=警报('存在记录')
如果未Page.ClientScript.IsStartUpScriptRegistered(Me.GetType(),alertscript)然后
Page.ClientScript.RegisterStartUpScript(Me.GetType(),alertscript,脚本,真) 万一
万一
你会做它像上面,你应该replaceDataStore.Record.Exists(theRecord)与条件,检查数据库记录是否存在
How can I call a javascript function from code behind?
The most popular response is "ScriptManager.RegisterStartupScript
" however, that does not work in my situation.
I have a vb class that is doing a database check to see if a record exists. If exists, then call a javascript function to display an alert("Record exists")
So I am doing something like
Dim strMessage as string = "javascript:RecordExists('Param');"
How do I call this function from my vb.net class?
If DataStore.Record.Exists(theRecord) Then
Dim script As String = "alert('Record exists')"
If Not Page.ClientScript.IsStartUpScriptRegistered(Me.GetType(), "alertscript") Then
Page.ClientScript.RegisterStartUpScript(Me.GetType(), "alertscript", script, True)
End If
End If
you would do it like above, where you should replaceDataStore.Record.Exists(theRecord) with condition that checks database record exists
这篇关于从vb.net code后面调用JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!