PageMethods not working if the website is created as a Visual C# ASP.Net Web Application in VS2015

  • Thread starter Thread starter Cenk Camkoy
  • Start date Start date
C

Cenk Camkoy

Guest
I am a newbie in web developing with VS (Visual Studio). I have the following problem and would appreciate it very much if you could share your view on this.

PROBLEM: PageMethods works OK if I create a new website in VS via [File] - [New Web Site] - [ASP.NET Empty Web Site] as per the files given below. But if I create a new website in VS via [File] - [New Project] - [Visual C# ASP.NET Web Application] then PageMethods do NOT work as per the files given below. Moreover, I can not run any method created in aspx.cs files!

Obviously, I am missing a basic step/concept but I can not see it unfortunately!

ASPX File:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test4.aspx.cs" Inherits="ETDBWebApplication1.Content.Test.Test4" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="~/Scripts/jquery-3.5.1.js"></script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="sm1" EnablePageMethods="true" />
<div>
<script type="text/javascript">
function getValues() {
var text1 = $('#txt1').val();
PageMethods.GetValues(text1, getValues_Success, getValues_Fail);
}
function getValues_Success(msg){
$('#div1').html(msg);
}
function getValues_Fail(msg) {
alert(msg.get_message());
}
</script>
<input type="text" id="txt1" />
<br />
<input type="button" onclick="getValues();" value="get values"/>
<br />
<br />
<div id="div1"></div>
</div>
</form></body>
</html>


Continue reading...
 
Back
Top