I have this jQuery code that runs from a form submission and loops to insert a certain number of records into an SQL table. The ajax portion of the code calls a VB function in a webmatrix page called Helpers.vbhtml
function InsertSheeter()
{
var textDate = $('#textDate').val()
var Workorder = $('#textWorkorder').val()
var Material = $('#dropdownMaterial').val()
var Shift = $('#dropdownShift').val()
var Sheeter = $('#dropdownSheeter').val()
var FoilNum1 = $('#textFoilNum1').val()
var FoilNum2 = $('#textFoilNum2').val()
var FoilNum3 = $('#textFoilNum3').val()
var Printline = $('#dropdownPrintline').val()
var Section = $('#dropdownSection').val()
var Comments = $('#textComments').val()
var Employee = $('#dropdownEmployees').val()
var a = 0
while (a < Section)
{
switch (a)
{
case 0:
blockSection = "1"
break;
case 1:
blockSection = "2"
break;
case 2:
blockSection = "3"
break;
}
var str = {pDate: textDate, pSheeter: Sheeter, pShift: Shift,
pEmployee: Employee, pWorkorder: Workorder, pBlockSection: blockSection,
pComments: Comments, pFoilNum1: FoilNum1, pFoilNum2: FoilNum2,
pFoilNum3: FoilNum3, pPrintline: Printline, pMaterial: Material}
$.ajax(
{
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Helpers.vbhtml/InsertSheeter",
data: JSON.stringify(str),
dataType: "json",
success: function(data)
{
OpenReports(Workorder, data.d)
},
error: function (xhr, errorType, exception) {
var errorMessage = exception || xhr.statusText;
alert(errorMessage);
}
});
a++;
}
}
This is the VB.NET function that gets called:
I created according to how I understand the documentation, a webservice using a vbhtml page in the App_Code directory. Here is a snippet of my vb code InsertSheeter as previously referenced in this post.
@Imports Microsoft.VisualBasic
@Imports System
@Imports System.Web
@Imports System.Web.Services
@Imports System.Xml.Serialization
@Functions
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
<WebMethod>
Public Shared Function InsertSheeter(ByVal pDate As DateTime, ByVal pSheeter As String, ByVal pShift As String,
ByVal pEmployee As String, ByVal pWorkorder As String,
ByVal pBlockSection As String, ByVal pComments As String, ByVal pFoilNum1 As String,
ByVal pFoilNum2 As String, ByVal pFoilNum3 As String, ByVal pPrintline As String,
ByVal pMaterial As String) As String
Dim db As Database
db = Database.Open("Nomex")
Dim strQuery As String
Dim pBlockNumber As String
pBlockNumber = GetBlockNumber(pBlockSection, pWorkorder, pSheeter, pMaterial)
strQuery = "INSERT INTO dbo.NomexSheeter (SheeterDate, Sheeter, Shift, Employee, WorkOrder, BlockNumber, BlockSection, " _
& "Comments, FoilNum_1, FoilNum_2, FoilNum_3, PrintLine, Material) " _
& "VALUES (@0, @1, @2, @3, @4, " _
& "@5, @6, @7, @8, @9, @10, @11, @12)"
db.Execute(strQuery, pDate, pSheeter, pShift, pEmployee, pWorkorder, pBlockNumber, pBlockSection,
pComments, pFoilNum1, pFoilNum2, pFoilNum3, pPrintline, pMaterial)
db.Close
Return pBlockNumber
End Function
End Functions
after calling the jQuery function InsertSheeter() i still get the 404 Forbidden error. I don't understand what I am doing wrong. Webmatrix documentation and posts online seem to support this idea.
Requested URL: /Helpers.vbhtml/ValidateWorkorder
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1022 – Ryan Mar 07 '14 at 18:13