Posted on Mar 28, 2011 (permalink)
Hi All,
I have defined a Shared Function in the code behind and a javascript function to call the webmethod. Also, I have EnablePageMethogs set to true in ScriptManager.
However, nothing seems to be working.
Below is the code behind and javascript code used.
Code Behind:-
[System.Web.Services.WebMethod()] public static ArrayList getSubCategoriesByCategoryID(int categoryID) {
SqlConnection test = new SqlConnection(ConfigurationManager.ConnectionStrings["test"].ConnectionString); ArrayList subCategories = new ArrayList();
try { string description; if (conn.State == ConnectionState.Closed) { test.Open(); } SqlCommand getSubCategories = new SqlCommand(); getSubCategories.CommandType = CommandType.StoredProcedure; getSubCategories.CommandText = "dbo.test_proc"; getSubCategories.Parameters.Add("@categoryid", SqlDbType.VarChar,12).Value = categoryID; getSubCategories.Connection = test;
SqlDataReader dr = getSubCategories.ExecuteReader();
if (dr.HasRows) {
while (dr.Read()) {
description = (string)dr.GetValue(0); subCategories.Add(description); } } } catch (Exception ex) { ex.ToString(); }
return subCategories; // Return toReturn }
and Javascript:-
function getSubCategory(sender, args) { var categoryID = sender.get_value();
PageMethods.getSubCategoriesByCategoryID(categoryID, CallSuccess);
}
Thanks
Any Suggestions?
Back to Top
UI controls for ASP.NET AJAX, MVC, WPF, Silverlight, Windows Forms and Windows Phone. Visual Studio productivity tools. Reporting and data layer solutions.
HTML5 / JavaScript tools for Web and Mobile applications
Functional, Performance, Load and Mobile Software Testing
CMS, Mobile Web, Ecommerce, Emarketing, Social Media
Project management software inspired by Agile best practices
It seems you haven't bookmarked any pages. Fix that by clicking the button below