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

  • SEARCH
  • Home
  • 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 7709931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:59:09+00:00 2026-06-01T00:59:09+00:00

I have read a lot about jquery and i have a simple webservice that

  • 0

I have read a lot about jquery and i have a simple webservice that returns a method. Now i want to call that webservice with jquery in dotnetnuke but I get an error saying file not found (Error Number 404).

Here is my code:

WEBSERVICE

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;


/// <summary>
/// Summary description for TestPost
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment       the following line. 
[System.Web.Script.Services.ScriptService]
public class TestPost : System.Web.Services.WebService {


public TestPost () {


    //Uncomment the following line if using designed components 
    //InitializeComponent(); 
}


[WebMethod]
[System.Web.Script.Services.ScriptMethod()]
public Names[] GetNames()
{
    List<Names> list = new List<Names>();
    DataTable dt = DataStore.GetDataTable();
    foreach (DataRow row in dt.Rows)
    {
        Names _names = new Names();
        _names.FirstName = row["Name"].ToString();
        _names.Age = row["age"].ToString();
        list.Add(_names);
    }
    return list.ToArray();
}

}
public class DataStore
{
    public static DataTable GetDataTable()
{      
    DataTable dt = new DataTable("Names");
    DataColumn dc1 = new DataColumn("Name");
    DataColumn dc2 = new DataColumn("Age");
    dt.Columns.AddRange(new DataColumn[] { dc1, dc2 });
    DataRow dr1 = dt.NewRow();
    dr1[0] = "Ahmed";
    dr1[1] = "27";
    DataRow dr2 = dt.NewRow();
    dr2[0] = "Peter";
    dr2[1] = "30";
    DataRow dr3 = dt.NewRow();
    dr3[0] = "John";
    dr3[1] = "20";
    DataRow dr4 = dt.NewRow();
    dr4[0] = "Ali";
    dr4[1] = "30";
    dt.Rows.Add(dr1);
    dt.Rows.Add(dr2);
    dt.Rows.Add(dr3);
    dt.Rows.Add(dr4);
    return dt;
}
}


public class Names
{
private string _firstName;
private string _age;
public string FirstName
{
    get { return _firstName; }
    set { _firstName = value; }
}
public string Age
{
    get { return _age; }
    set { _age = value; }
}
}

MARKUP

<%@ Control language="C#" Inherits="GlobalPay.Modules.MainBoard.ViewMainBoard"     CodeFile="ViewMainBoard.ascx.cs" AutoEventWireup="true"%>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %>  

<script type="text/javascript">
jQuery = jQuery.noConflict();
    jQuery(document).ready(function() {
        jQuery("#Button1").click(function(event) {
            jQuery.ajax({
                 type: "POST",
                 url: "TestPost.aspx/GetNames",
                 data: "{}",
                 contentType: "application/json; charset=utf-8",
                 dataType: "json",
                 success: function(msg) {
                      Success: " + msg);
                 },
                 error: function(msg) {
                      Failed: " + msg.status + ": " + msg.statusText);
                 }
             });   
        });  
    });

function AjaxSucceeded(result) {  
          result.d);
      }  
function AjaxFailed(result) {  
      result.status + ' ' + result.statusText);  
  }    


</script>


<body> 

<div id="container">
<asp:TextBox runat="server" ID="PractiseTextbox"></asp:TextBox>
<input id="Button1" type="button" value="button"/>    

<div id="footer">

</div>


</div>

</body>

CODE BEHIND

using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.IO;
using System.Web.Services;
using AjaxControlToolkit;


using DotNetNuke;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Modules.Actions;
using DotNetNuke.Security;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Localization;


namespace GlobalPay.Modules.MainBoard
{
partial class ViewMainBoard : PortalModuleBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        DotNetNuke.Framework.jQuery.RequestRegistration();


        //register the accordion script
        if (!DotNetNuke.UI.Utilities.ClientAPI.IsClientScriptBlockRegistered(Page, "ui.core.js"))
        {
            DotNetNuke.UI.Utilities.ClientAPI.RegisterClientScriptBlock(Page, 
                "ui.core.js", "<script src=\"" + Request.ApplicationPath +
                "/jquery-1.4.1.min.js\" type=\"text/javascript\"></script>");
        }


        ScriptManager objScriptManager;
        ServiceReference objServiceReference;


        if (DotNetNuke.Framework.AJAX.IsInstalled())
        {
            objScriptManager = ScriptManager.GetCurrent(this.Page);
            objServiceReference = new ServiceReference();
            objServiceReference.Path = ResolveUrl("TestPost.asmx");
            objScriptManager.Services.Add(objServiceReference);
        }
    }
}
}

Please review my code to see if i am doing something wrong.

  • 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-01T00:59:10+00:00Added an answer on June 1, 2026 at 12:59 am

    Looks to me like the path to the ASMX file isn’t correct (hence the 404). Try this:

    url: '<%=ResolveUrl("TestPost.asmx/GetNames")%>'
    

    Since you’re calling this from a DNN module, it’s unlikely that a path relative to the current module control will get to the right place; you need the path to be relative to the page, and you won’t know that at compile time. ResolveUrl will give you a URL that’ll work on the current page, regardless of where that is.

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

Sidebar

Related Questions

I have read a lot about this issue but mine still seems to be
This should be something simple, I have read a lot about the organization browser
I have read a lot about this! But I can't make a clear idea!
I have read a lot about MVC design pattern, but some of the things
I have read a lot about preventing race conditions, but typically with one record
I have read a lot about unit testing, but I still haven't found any
I read a lot of posts about the problem I have, but haven't been
I have read a lot about projective geometry and cross ratio, but I don´t
i have read a lot about what im asking, but the closest thing i
I have already read a lot about C++ exceptions and what i see, that

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.