谁能帮我在我的 javascript 函数中调用我的 VB.NET 方法?我的方法不是共享/静态的,也不返回任何东西。它只是简单地将数据保存到数据库并重定向用户。请帮助我,这是我的代码:
VB法
Public Function SaveVehicles()
Dim res As Boolean
If res = True Then
Dim sModel As String = cboModel.SelectedValue
Dim sVariant As String = cboVariant.SelectedValue
Dim sColor As String = cboColor.SelectedValue
cboModel.SelectedValue = sModel
cboVariant.SelectedValue = sVariant
cboColor.SelectedValue = sColor
Dim oData As New WebServVehSwapping
Dim strSql As String
Dim sDealer As String
Dim sUserName As String
'sDealer = "TBP01"
sDealer = Trim(Request.QueryString("dealercode"))
If sDealer = "" Then sDealer = "TBP01"
sUserName = "User1"
'------------------------------------------
strSql = oData.InsertTblRequirement( _
sDealer _
, Now.ToString _
, sUserName _
, cboColor.Text.Trim _
, cboModel.Text.Trim _
, cboVariant.Text.Trim, "Open")
MsgBox("OKAY")
Response.Redirect("MyRequirements.aspx?DealerCode=" & sDealer)
Else
'do Nothing
End If
End Function
这是我的 Javascript 函数
function ConfirmView()
{
var Ok = confirm('There is/are existing vehicle(s) in Network Vehiches for sale, View Vehicle(s)?');
if(Ok==true)
{
location.href = 'NetworkVehiclesforSale.aspx';
return false;
}
else if (Ok!=true)
{
//THE VB METHOD GOES HERE
}
}
我已经尝试过回调处理程序,它只适用于返回某些东西/字符串的函数
我试过 Pagemethod 但它只适用于静态/共享功能。请帮助我,我真的很需要它。请看。谢谢