Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8528873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:54:01+00:00 2026-06-11T08:54:01+00:00

I have a page (default.aspx) with codebehind. The a$.ajax url is getting a response

  • 0

I have a page (default.aspx) with codebehind. The a$.ajax url is getting a response from one place, and on its success I want to call the codebehind function.

(In case I made a mistake while obfuscating the code, the $.ajax works perfectly and I get the desired response).

How is this possible?

Code I’m using:

    jQuery.support.cors = true; // force cross-site scripting (as of jQuery 1.5)
    $.ajax({
                type: "POST",
                url: URL,
                data: parameters,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (response) {

                    var resultCount = response.d
                    alert("*** RESULT ****" + resultFields);;
                    var string = StringReturn(); // the codebehind
                    alert(string);
                },
                error: function (e) {
                    alert("Unavailable");
                }
            });

Codebehind:

        [WebMethod]
protected static string StringReturn()
{
    return "StringReturn() success";
}

However, I’m getting error messages saying that StringReturn isn’t a valid function.

Any help would be appreciated?

I’ve added the following lines of code to the page as advised:

    <asp:ScriptManager ID="ScriptMgr" runat="server" EnablePageMethods="true"> </asp:ScriptManager>

I’ve also changed the code to call a javascript function on the Success event, the function being:

    function HelloWorlds() {

        alert("HelloWorld() method");
        message = PageMethods.StringReturn();
        message.toString();
        alert(message);
    }

however that doesn’t appear to work. What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:54:02+00:00Added an answer on June 11, 2026 at 8:54 am

    You need to have a scripmanager on your page and then you can call it like this PageMethods.StringReturn()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASPX Page: <%@ Page Language=C# MasterPageFile=~/site.Master AutoEventWireup=true CodeBehind=Default.aspx.cs Inherits=myProject.Presentation.Web.Default src=Default.aspx.cs %>
I have an ASP.Net Page, aspx with its default form. I have a Submit
I have a page, Default.aspx, with its own code-behind file like this: using System;
I have the following webform: <%@ Page Language=C# AutoEventWireup=true CodeBehind=Default.aspx.cs Inherits=TestWebApp.Default %> <!DOCTYPE html
In my aspx page I have a tr which is set visible=false by default.
In my .aspx page I have; <%@ Page Language=VB AutoEventWireup=false CodeFile=Default.aspx.vb Inherits=_Default AspCompat=True %>
I have GridView on my page: <%@ Page Language=C# AutoEventWireup=true CodeFile=Default.aspx.cs Inherits=_Default %> <!DOCTYPE
On my default.aspx page I have a bunch of divs with an ID and
I have a simple page per below: Default.aspx <%@ Page Language=C# AutoEventWireup=true CodeFile=Default.aspx.cs Inherits=_Default
I have page (Default1.aspx) in which I am redirecting to another page (Default2.aspx) using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.