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 764281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:41:57+00:00 2026-05-14T16:41:57+00:00

I am wondering if RegisterTypeForAjax isn’t working correctly. I am getting the error noted

  • 0

I am wondering if RegisterTypeForAjax isn’t working correctly. I am getting the error noted at the end of the code block below. Sample is from here:
http://www.ajaxtutorials.com/asp-net-ajax-quickstart/tutorial-introduction-to-ajax-in-asp-net-2-0-and-c/

Any ideas as to why I’m getting this error? Thanks.

ASP .NET 2.0 C#

Here is the code-behind:

using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using AjaxPro;


namespace WebApplication1
{
    public partial class Ajax_CSharp : System.Web.UI.Page
    {
        protected override void OnInit( EventArgs e )
        {
            base.OnInit( e );
            Load += new EventHandler( Page_Load );
        }

        protected void Page_Load( object sender, EventArgs e )
        {
            Utility.RegisterTypeForAjax( typeof( Ajax_CSharp ) );
        }

        [ AjaxMethod( HttpSessionStateRequirement.ReadWrite ) ]
        public string GetData()
        {
            // method gets a row from the db and returns a string.
        }
}

Here is the ASPX page:

<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Ajax_CSharp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
       function GetData()
       {
          var response;
          Ajax_CSharp.GetData( GetData_CallBack );
       }

       function GetData_CallBack( response )
       {
          var response = response.value;

          if ( response == "Empty" )
          {
             alert( "No Record Found." );
          }
          else if ( response == "Error" )
          {
             alert( "An Error Occurred in Accessing the Database !!!" );
          }
          else
          {
             var arr = response.split( "~" );
             var empID = arr[0].split( "," );
             var empName = arr[1].split( "," );

             document.getElementById( 'dlistEmployee' ).length = 0;

             for ( var i = 0; i < empID.Length; i++ )
             {
                var o = document.createElement( "option" );
                o.value = empID[i];
                o.text = empName[i];
                document.getElementById( 'dlistEmployee' ).add( o );
             }
          }
       }

       function dodisplay()
       {
          var selIndex = document.getElementById( "dlistEmployee" ).selectedIndex;
          var empName = document.getElementById( "dlistEmployee" ).options( selIndex ).text;
          var empID = document.getElementById( "dlistEmployee" ).options( selIndex ).value;

          document.getElementById( "lblResult" ).innerHTML = "You have selected " + empName + " (ID: " + empID + " )";
       }

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div style="text-align: center;">
        <input id="btnGetData" 
               onclick="GetData();" 
               type="button" 
               value="To Get Employee Data From DB" style="width: 203px" />
        &nbsp;&nbsp;
        <asp:DropDownList id="dlistEmployee" OnTextChanged="dodisplay();" />
        <asp:Label id="lblResult" runat="server" Text="No Record Selected" />
    </div>
    </form>
</body>
</html>

Run it and click on the button and I get this error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2; MS-RTC LM 8)
Timestamp: Mon, 26 Apr 2010 17:22:44 UTC

Message: ‘Ajax_CSharp’ is undefined
Line: 13
Char: 11
Code: 0
URI: http://localhost:4678/Default.aspx

  • 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-05-14T16:41:57+00:00Added an answer on May 14, 2026 at 4:41 pm

    Try using the full name.

    In this case change:

    Ajax_CSharp.GetData( GetData_CallBack );
    

    to

    WebApplication1.Ajax_CSharp.GetData( GetData_CallBack );
    

    What is happening is that page has no idea what Ajax_CSharp is. When using AjaxPro you always should use the FullName of a class, which is Namespace.ClassName.

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

Sidebar

Related Questions

Wondering if anyone has gotten the infamous database is locked error from Trac and
Wondering if anyone knows a nice way to execute a Java command-line program from
Wondering if there is any way to get the lambda expressions that result from
Wondering if it's possible to change a value returned from a queryset before sending
Wondering if its possible to communication from javascript to flash without the use of
Wondering how I can change the php session id from PHPSESSID to something else
Wondering if it's possible to process HAML from database entries. My model currently processes
Wondering what the point of if (self = [super ... in the following code
Wondering if there is any Text to Speech software available as a plug in
Wondering if I need to do something in my swf to be able to

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.