Error with Ajax Control

Last post 07-08-2008 9:57 AM by dbrook007. 32 replies.
Page 1 of 3 (33 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 07-07-2008 2:15 PM

    Error with Ajax Control

    I tried the getting started code in vb from:

     

    ..and converted to C# for asp.net 2.0

    But, when I try it, I get this error:

    "Microsoft JScript runtime error: 'DataService' is undefined"

    in a message box.

    This is the markup:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" >
                <Services>
                    <asp:ServiceReference Path="~/DataService.asmx" />
                </Services>
            </asp:ScriptManager>
            <div>
                <br />
                <br />
                &nbsp;<AjaxData:GridView ID="MyGrid" runat="server">
                </AjaxData:GridView>
                <script type="text/javascript">
                    var _grid = null;
                    function pageLoad(sender, e)
                    {
                      _grid = $find('<%= MyGrid.ClientID %>');
                      DataService.TestData(onLoadSuccess);
                    }
                          
                    function onLoadSuccess(result)
                    {
                      _grid.set_dataSource(result.rows);
                      _grid.dataBind();
                    }      
                </script>
            </div>
        </form>
    </body>
    </html>

    I don't know what is wrong?

    Thanks - Darren

     

    dbrook007
  •  Advertisement

    Featured Advertisement

     
  • 07-07-2008 2:16 PM In reply to

    Re: Error with Ajax Control

    ps: the above is from:

    http://dotnetslackers.com/Community/blogs/sonukapoor/archive/2008/06/13/ajaxdatacontrols-adc-faq-how-to-get-started-with-the-ajaxdatacontrols-with-visual-studio-2005.aspx

    thanks - darren

     

    dbrook007
  • 07-07-2008 2:21 PM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Error with Ajax Control

    Does the DataService.asmx file exist in the root folder?

    Check the viewsource and find the link with .asmx/debug or something and enter that in the browser. Let me know what result you get.

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 07-07-2008 2:27 PM In reply to

    • xxxd
    • Top 10 Contributor
    • Joined on 12-18-2006
    • Slacker
    • Points 19,057

    Re: Error with Ajax Control

     Were you using exactly the same source code and had the error?

    Have you created a webservice called dataservice.asmx? Can you test the web service seperately?

  • 07-07-2008 2:30 PM In reply to

    • xxxd
    • Top 10 Contributor
    • Joined on 12-18-2006
    • Slacker
    • Points 19,057

    Re: Error with Ajax Control

    Sorry, sonu, clashed with yours.

  • 07-07-2008 2:31 PM In reply to

    Re: Error with Ajax Control

    Hi,

    Sonu:

    Does the DataService.asmx file exist in the root folder?

    Check the viewsource and find the link with .asmx/debug or something and enter that in the browser. Let me know what result you get.

     

    DataService.asmx is in the root folder.  The webservice tested by itself seems to work ok. This is the viewsource:


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>
        Untitled Page
    </title></head>
    <body>
        <form name="form1" method="post" action="Default.aspx" id="form1">
    <div>
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
    <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE1NTc0OTQ3NTgPZBYCAgMPZBYCAgEPD2RkZGTLjtkdS8tqInngTYwnY1XtueB1/Q==" />
    </div>

    <script type="text/javascript">
    //<![CDATA[
    var theForm = document.forms['form1'];
    if (!theForm) {
        theForm = document.form1;
    }
    function __doPostBack(eventTarget, eventArgument) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTARGUMENT.value = eventArgument;
            theForm.submit();
        }
    }
    //]]>
    </script>


    <script src="/ADCProject01/WebResource.axd?d=ar6Q9T2kjogBYOljiis-xQ2&amp;t=633370439767968750" type="text/javascript"></script>


    <script src="/ADCProject01/ScriptResource.axd?d=ZVpcUSaHOaa0VBS4SGdcSgTFlh6gFanToS-12NH1YFhdf0LUDomxCtcN-MLe-71CjUOct1FJjwhCbueIqE1dzHMl-hkNyL8ncqnHo6RwF7g1&amp;t=633408516571687500" type="text/javascript"></script>
    <script src="/ADCProject01/ScriptResource.axd?d=ZVpcUSaHOaa0VBS4SGdcSgTFlh6gFanToS-12NH1YFhdf0LUDomxCtcN-MLe-71CjUOct1FJjwhCbueIqE1dzNnyyk1yOZtgrNq8H2rPY-CdHWSxNPPaCohRPkWBK41l0&amp;t=633408516571687500" type="text/javascript"></script>
    <script src="/ADCProject01/WebResource.axd?d=ymY3wVcFaoi-E8bWu02SCG6OcFetiGYttwajJ98klu-05NKwtETvExfS0SECaChmvJ8fUT72mYqOsuxA_Oiblw2&amp;t=633351028380000000" type="text/javascript"></script>
    <script src="/ADCProject01/WebResource.axd?d=ymY3wVcFaoi-E8bWu02SCG6OcFetiGYttwajJ98klu9jdeSO_ACnPWTNIZbXDwP_5lczRpHsfjcQWM1ZPYvmYg2&amp;t=633351028380000000" type="text/javascript"></script>
    <script src="/ADCProject01/WebResource.axd?d=ymY3wVcFaoi-E8bWu02SCG6OcFetiGYttwajJ98klu-mkQGsAlBL768OrQd_lNU8V2n8Ixue0u3S9mz5TAE2iFP-jX03s5xtrHgCEg44UujumurMu9tOOVOgnCcx8STB0&amp;t=633351028380000000" type="text/javascript"></script>
    <script src="DataService.asmx/jsdebug" type="text/javascript"></script>
            <script type="text/javascript">
    //<![CDATA[
    Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));
    Sys.WebForms.PageRequestManager.getInstance()._updateControls([, [, [, 90);
    //]]>
    </script>

            <div>
                <br />
                <br />
                &nbsp;<table id="MyGrid">

    </table>
                <script type="text/javascript">
                    var _grid = null;
                    function pageLoad(sender, e)
                    {
                      _grid = $find('MyGrid');
                      DataService.TestData(onLoadSuccess);
                    }
                          
                    function onLoadSuccess(result)
                    {
                      _grid.set_dataSource(result.rows);
                      _grid.dataBind();
                    }      
                </script>
            </div>
       

    <script type="text/javascript">
    //<![CDATA[
    Sys.Application.initialize();
    Sys.Application.add_init(function() {
        $create(AjaxDataControls.GridView, null, null, null, $get("MyGrid"));
    });
    //]]>
    </script>
    </form>
    </body>
    </html>

     

    Thanks - Darren

     

    dbrook007
  • 07-07-2008 2:36 PM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Error with Ajax Control

    Can you run this in the browser and tell us what you see?

    http://REPLACE_ME/DataService.asmx/jsdebug

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 07-07-2008 2:55 PM In reply to

    Re: Error with Ajax Control

    Sure... I see this:

    Server Error in '/ADCProject01' Application.

    Type: 'Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview' cannot be found.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentException: Type: 'Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview' cannot be found.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [ArgumentException: Type: 'Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview' cannot be found.]
    System.Web.Configuration.ConvertersCollection.CreateConverters() +472
    System.Web.Configuration.ApplicationSettings..ctor() +94
    System.Web.Script.Services.WebServiceData..ctor(WebServiceTypeData typeData) +108
    System.Web.Script.Services.WebServiceData..ctor(Type type, Boolean pageMethods) +74
    System.Web.Script.Services.WebServiceData.GetWebServiceData(HttpContext context, String virtualPath, Boolean failIfNoData, Boolean pageMethods) +235
    System.Web.Script.Services.WebServiceClientProxyGenerator.GetClientProxyScript(HttpContext context) +58
    System.Web.Script.Services.RestClientProxyHandler.ProcessRequest(HttpContext context) +14
    System.Web.Script.Services.HandlerWrapper.ProcessRequest(HttpContext context) +10
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358


    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


    Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433

     


    Thanks - Darren

    dbrook007
  • 07-07-2008 3:03 PM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Error with Ajax Control

    You are missing the converters. Check the converters section in my web.config. You will also need to add the Microsoft.Web.Preview.dll dll into your project, which is also in my project.

    http://dotnetslackers.com/Community/blogs/sonukapoor/ADCSampleWebsite.zip

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 07-07-2008 3:13 PM In reply to

    Re: Error with Ajax Control

    I did follow the instructions on the webpage.... This is a snapshot of my web.config.:

        <scripting>
                <webServices>
                    <!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
                    <jsonSerialization maxJsonLength="4194304">
                        <converters>
                            <add name="DataSetConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview"/>
                            <add name="DataRowConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter, Microsoft.Web.Preview"/>
                            <add name="DataTableConverter" type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter, Microsoft.Web.Preview"/>
                        </converters>
                    </jsonSerialization>
                    <!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
                    <!--
            <authenticationService enabled="true" requireSSL = "true|false"/>
          -->
                    <!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
               and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
               writeAccessProperties attributes. -->
                    <!--
          <profileService enabled="true"
                          readAccessProperties="propertyname1,propertyname2"
                          writeAccessProperties="propertyname1,propertyname2" />
          -->
                </webServices>
                <!--
          <scriptResourceHandler enableCompression="true" enableCaching="true" />
          -->
            </scripting>

     

    and the microsoft.web.preview.dll is in teh project too.

     

    Thanks - Darren

     

     

     

    dbrook007
  • 07-07-2008 3:18 PM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Error with Ajax Control

    Hm... That seems to be fine to me. Are you using the latest microsoft.web.preview.dll? Can you restart IIS (maybe its using some old dlls somewhere). Can you run my project?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 07-07-2008 3:23 PM In reply to

    Re: Error with Ajax Control

    I am not using IIS.  I am developing locally using Windows XP Pro (SP3).  I don't have a server available to me.

    If Microsoft.Web.Preview.Dll is needed on the server, is this not going to be a problem in a shared hosting environment that has not got ASP.Net Futures installed?

    Thanks - Darren

     

     

    dbrook007
  • 07-07-2008 3:29 PM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Error with Ajax Control

    You will just need the dll in your bin folder - that should not be a problem in my view.

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
  • 07-07-2008 3:40 PM In reply to

    Re: Error with Ajax Control

    I still have the same problem locally?

    Thanks - Darren

     

     

    dbrook007
  • 07-07-2008 3:45 PM In reply to

    • sonu
    • Top 10 Contributor
    • Joined on 05-22-2006
    • Montreal / Canada
    • Slacker
    • Points 12,183
    • MVP

    Re: Error with Ajax Control

    Even with my version?

    [MVP since 2005] [MCAD]
    Webmaster of DotNetSlackers
    Question or Suggestion?
    Feel free to ask my any .NET question
    Our Posting FAQ
Page 1 of 3 (33 items) 1 2 3 Next >