This is a migrated thread and some comments may be shown as answers.

Error on AJAX web service Call

2 Answers 70 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Brandon Slezak
Top achievements
Rank 2
Brandon Slezak asked on 18 Nov 2010, 05:30 AM
Hi All,

I'm trying out the Client side insert/update/delete sample for RadGrid and am banging my head on a wall trying to figure this out.

In a nutshell when I make the AJAX call to the server I get this Message:

Microsoft JScript runtime error: Function expected


I have the web service setup, and put the service reference in the ASPX page in a telerik handler.  And I understand there is a callback function involved to repaint the grid, but I never get the callback.

Incidentally the web service is being invoked and the database is updated.

Any and all advice is greatly appreciated!


<

 

telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

 

 

<script type="text/javascript">

 

 

function updateChanges()

 

{

ProductUpdate.AddProductLineItem(15705, 32608, 2, 1, 1, 1, 1, updateGrid);

 

}

 

 

function updateGrid(result)

 

{

 

var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();

 

 

 

 

var grid = $find("<%= RadGrid1.ClientID %>");

 

grid.repaint();

}

 

 

</script>

 

</

 

telerik:RadCodeBlock>


 

<

 

telerik:RadScriptManager ID="RadScriptManager1" runat="server">

 

 

<Services>

 

 

<asp:ServiceReference Path="ProductUpdate.asmx" />

 

 

</Services>

 

 

</telerik:RadScriptManager>


 

using

 

System;

 

 

 

using

 

System.Collections.Generic;

 

 

 

using

 

System.Linq;

 

 

 

using

 

System.Web;

 

 

 

using

 

System.Web.Services;

 

 

 

using

 

System.Web.Script.Services;

 

 

 

using

 

System.Data;

 

 

 

using

 

System.Data.SqlClient;

 

 

 

using

 

System.Configuration;

 

 

 

///

 

<summary>

 

///

 

Summary description for ProductUpdate

 

 

 

 

///

 

</summary>

 

 

 

 

[

WebService(Namespace = "http://tempuri.org/")]

 

[

WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

 

[

ScriptService]

 

 

 

// 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 ProductUpdate : System.Web.Services.WebService {

 

 

public ProductUpdate () {

 

 

//Uncomment the following line if using designed components

 

 

 

 

 

//InitializeComponent();

 

 

 

 

}

[

WebMethod (EnableSession=true)]

 

 

public string AddProductLineItem(int bidID, int bidAddressID, int productID, int quantity, double originalPrice, double price) {

 

 

SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["HarvestWSConnectionString"].ConnectionString);

 

conn.Open();

 

string sql = @"INSERT INTO BidDetail (BidId, BidAddressID, ProductID, Quantity, OriginalPrice, Price)

 

VALUES (@BidId, @BidAddressID, @ProductID, @Quantity, @OriginalPrice, @Price)"

 

;

 

 

SqlCommand cmd = new SqlCommand(sql, conn);

 

cmd.Parameters.Add(

new SqlParameter("@BidID", bidID));

 

cmd.Parameters.Add(

new SqlParameter("@BidAddressID", bidAddressID));

 

cmd.Parameters.Add(

new SqlParameter("@ProductID", productID));

 

cmd.Parameters.Add(

new SqlParameter("@Quantity", quantity));

 

cmd.Parameters.Add(

new SqlParameter("@OriginalPrice", originalPrice));

 

cmd.Parameters.Add(

new SqlParameter("@Price", price));

 

 

 

try

 

 

 

 

{

cmd.ExecuteNonQuery();

}

 

catch (Exception ex)

 

{

 

Console.WriteLine(ex.Message);

 

}

conn.Close();

 

return "Brandon was here";

 

}

 

}

 


2 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 23 Nov 2010, 04:08 PM
Hello Brandon,

The client-side repaint() method of RadGrid does not do callbacks or postbacks. It mostly checks for misalignment of the control when using certain functionalities that may change its layout and fixes them by rerendering the grid, but all this happens on the client.

One thing which I do not see in your code is setting the datasource and calling databind() for the RadGrid control. Where do you do that in your project? Could you please confirm if this is not the reason for the problematic behavior?

Best wishes,
Tsvetina
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Brandon Slezak
Top achievements
Rank 2
answered on 28 Nov 2010, 05:08 AM
I gave up and just used the RadAjaxManager object and manually invoked the Ajax command when I wanted and it worked much better than using the RadScriptManager.

It must have been some argument serialization issue but I never researched it more.
Tags
Ajax
Asked by
Brandon Slezak
Top achievements
Rank 2
Answers by
Tsvetina
Telerik team
Brandon Slezak
Top achievements
Rank 2
Share this question
or