Hello guys,

Have a quite question anout Ajax. I am very new this topic,k so i dont much knowledge about this. Hope you can solve my problem. I was developing a web which use some ajax. But for some reason to wont call the server side script. I have tried the same thing with some simple example it works fine.

The problem which i am getting is here is the Object is undefined. But i have fillwed all the procedure. Here is my code.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register TagPrefix="MenuOpt" TagName="Menu" Src="~/MainHeader.ascx"%>
<%@ Register TagPrefix="Catopt" TagName="CatMenu" Src="~/CatagoryList.ascx"%>
<%@ Register TagPrefix="RightMenu" TagName="Menu" Src="~/RightMenuBar.ascx" %>
<%@ Register TagPrefix="BaseMenu" TagName="Menu" Src="~/BaseMenu.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
<link href="menustyle.css" rel="stylesheet" type="text/css" />
<html>
<head runat="server">
<title>Untitled Page</title>
<script src="utilites.js" type="text/javascript" language="javascript"></script>
<script src="menuscript.js" type="text/javascript" language="javascript"></script>
<script src="SeverCodeCall.js" type="text/javascript" language="javascript"></script>
<script type="text/javascript" >
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<MenuOpt:Menu id="MainHeader" runat="server" />
 
</div>
<table align="center" border=0 style="width: 823px; border-top-width: thin; border-left-width: thin; border-left-color: darkred; border-bottom-width: thin; border-bottom-color: darkred; border-top-color: darkred; border-right-width: thin; border-right-color: darkred;">
<tr>
<td align="left" style="width:47px ; border-top-width: thin; border-left-width: thin; border-left-color: darkred; border-bottom-width: thin; border-bottom-color: darkred; border-top-color: darkred; border-right-width: thin; border-right-color: darkred; height: 22px; vertical-align: top;" >
<Catopt:CatMenu align="left" ID="Catagory" runat="server" />
</td>
<td style="width: 383px; border-top-width: thin; border-left-width: thin; border-left-color: darkred; border-bottom-width: thin; border-bottom-color: darkred; border-top-color: darkred; border-right-width: thin; border-right-color: darkred; height: 22px; vertical-align: top; text-align: left;" >
<div id="MBodyDiv"></div>
</td>
<td align="right" style=" text-align:right; 186px; border-top-width: thin; border-left-width: thin; border-left-color: maroon; border-bottom-width: thin; border-bottom-color: maroon; border-top-color: maroon; border-right-width: thin; border-right-color: maroon; height: 22px; vertical-align: top;" >
<RightMenu:Menu align="right" ID="RightMenu" runat="server" />
</td>
</tr>
<tr>
<td colspan="3" style="border-top-width: thin; border-left-width: thin; border-left-color: maroon; border-bottom-width: thin; border-bottom-color: maroon; border-top-color: maroon; height: 19px; border-right-width: thin; border-right-color: maroon;">
<BaseMenu:Menu align="center" ID="BaseMenu" runat="server"/>
</td>
</tr>
</table>
</form>
</body>
</html>

This the actual page which use some master page along with this page.
And follwing is the server side code

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Ajax.Utility.RegisterTypeForAjax(GetType(_Default))
End Sub
<Ajax.AjaxMethod()> _
Public Function GetProductDes(ByVal ProdID As String) As String
Dim CatAdap As New CatagoryTableAdapters.CatagoryTableAdapter
Dim CatTable As Catagory.CatagoryDataTable
Dim ID As Integer = CInt(ProdID.Substring(11).ToString)
CatTable = CatAdap.GetDescription(ID)
If CatTable.Count > 0 Then
Return CatTable(0).Description.ToString
End If
Return Nothing
End Function

when i call the GetProductDes function through _default object through javascript i give a runtime error _default undefined
Does anybody have any idea of why the object is the created.

Sorry about the long post.

Thanks guys.

ssharish2005

looks like you are using the ajax.net library here, just a silly question, have you registered the http handler in the web.config file as per the instructions? Also there is a different method for registering user control classes for ajax handling. You can also check to see if the correct ajax functions are being added to the page again see the ajax.net site for examples of what you should be seeing at the top of the rendered page if the class has been registered correctly for ajax handling and for correctly registering a user control. The object not found is usually because the datatable is not being returned, so I would also check that your sql code is returning results and any variables you are sending are in fact being sent correctly. You can check to see that the ajaxmethod in your vb code is being called by putting a break point in it, that at least rules out a problem with the ajax library. while you do this you can check the variables and verify that a table (with rows) is indeed being created. The last check would be in your javascript code which handles the table when it's sent back remembering that its all case sensitive.

This article has been dead for over six months. Start a new discussion instead.