I need to call a VB code behind method from Javascript. Here's the code:
Master Page:
<%@ Master Language="VB" AutoEventWireup="true" CodeFile="Site.master.vb" Inherits="SiteMaster" %>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><%: Page.Title %></title>
<link href="/Images/Site/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link href="/CSS/Site.css" rel="stylesheet" />
<script src="/Scripts/js/Site.js" type="text/javascript"></script>
<script type="text/javascript">
function DKO(z) {
if (z.ctrlKey && z.altKey && (z.which == 70 || z.which == 102)) {
alert("Here");
PageMethods.GetOptionString(OnSuccess, OnError);
}
}
function OnSuccess(response) {
alert(response);
}
function OnError(error) {
alert(error);
}
</script>
<asp:ContentPlaceHolder ID="cphHead" runat="server" />
</head>
<body id="SiteBody" runat="server" style="background-color: black;" onkeydown="DKO(event)">
<form id="SiteForm" runat="server">
<asp:ScriptManager ID="smSite"
EnablePageMethods="true"
runat="server" />
VB Code Behind:
<WebMethod>
Private _
Shared _
Function GetOptionString _
(OptionString As String) _
As String
MsgBox("You're Here!!!")
Return True
End Function
Any Ideas why it doesn't work?