I've encountered an issue with a VB.Net page that calls a web method from JavaScript. It was functioning fine until just recently, and now it's not working at all. I'm feeling quite lost at the moment, so any guidance would be greatly appreciated.
Firstly, my page generates a list of items that can be clicked using the following line:
TicketHTML = TicketHTML + "<td><img src='../images/delete.png' Class='imgTicketClose' alt='Delete Task' onclick='DeleteTicket(" + row("id").ToString() + ")' /></td></tr>"
I'm confident this part is working since clicking on the item triggers a JavaScript popup. Therefore, I suspect the problem lies elsewhere.
Now onto my JavaScript:
function DeleteTicket(ticketID)
{
var answer = confirm("Do you really want to delete this task?")
if (answer)
{
PageMethods.DeleteTask(ticketID);
window.location.reload()
}
}
I believe the issue may be here because the web method doesn't seem to be called, and the page doesn't reload either. However, I'm puzzled as to why this might fail when the Javascript confirm dialog works just fine.
In the spirit of thoroughness, here's my web method code even though I know it's not being executed based on database profiling:
<System.Web.Services.WebMethod()>
Public Shared Sub DeleteTask(ticketID As Integer)
Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("Blueprint").ToString())
Dim cmd As New SqlCommand
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "spDeleteNonTicketItem"
cmd.Parameters.AddWithValue("@ItemID", ticketID)
cmd.Connection = conn
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
End Sub
So where should I turn next for help? Any suggestions or advice would be highly valued. Thank you
EDIT: Could there be anything in the web.config file causing issues with executing page methods? I've noticed this problem occurring with another entirely separate web method. I've also double-checked the integers passed into the javascript using alert(), and they are all valid.