I'm trying to create my own delete action for a custom tree. I already created the tree and the action, but now I'd like to call a webservice which can perform the delete code (just like umbraco does when deleting a node). I've already got the webservice, but I can't call it yet. I've found the following lines of code at several places inside the Umbraco source:
Now I need to add my ServiceReference to the ScriptManager, but I don't have a place to call this code.
In 'public class LoadLocationTree : BaseTree' I can't call this code, because I don't have the Page object. Is there some way to solve this and has anyone got experience with this?
I now have a better solution for this using jQuery. Here is part of my delete action:
public string Alias
{
get
{
return "delete";
}
}
public string JsFunctionName
{
get
{
return "DeleteCategory()";
}
}
public string JsSource
{
get
{
//Assign a function.
return @"function DeleteCategory()
{
if(confirm('Are you sure you want to delete this category and its children?'))
{
$.ajax({
type: ""POST"",
url: """ + IOHelper.ResolveUrl(SystemDirectories.Umbraco) + @"/customSections/products/ProductWebService.asmx/DeleteCategory"",
data: '{ ""categoryId"": ' + UmbClientMgr.mainTree().getActionNode().nodeId + '}',
contentType: ""application/json; charset=utf-8"",
dataType: ""json"",
success: function (msg) {
if(msg.d)
{
jQuery(window.top).trigger('nodeDeleted', []);
}
}
});
}
}";
}
}
I still call the custom webservice, but instead of calling UnidekCorporate.WebApplication.Sections.Products.ProductWebService.DeleteCategory(id) I go to the webservice path with an jQuery ajax call. This way I don't need to update the /umbraco/umbraco.aspx page. This sample works in Umbraco 4.5.
Call webservice from javascript within tree
Hello,
I'm trying to create my own delete action for a custom tree. I already created the tree and the action, but now I'd like to call a webservice which can perform the delete code (just like umbraco does when deleting a node). I've already got the webservice, but I can't call it yet. I've found the following lines of code at several places inside the Umbraco source:
Now I need to add my ServiceReference to the ScriptManager, but I don't have a place to call this code.
In 'public class LoadLocationTree : BaseTree' I can't call this code, because I don't have the Page object. Is there some way to solve this and has anyone got experience with this?
I've found a solution, but it's not really what I wanted. Currently I adjusted the umbraco.aspx page and changed the following:
This works, but it requires a small change in a page I´d rather not change. Does anybody have a better solution?
I now have a better solution for this using jQuery. Here is part of my delete action:
I still call the custom webservice, but instead of calling UnidekCorporate.WebApplication.Sections.Products.ProductWebService.DeleteCategory(id) I go to the webservice path with an jQuery ajax call. This way I don't need to update the /umbraco/umbraco.aspx page. This sample works in Umbraco 4.5.
Jeroen
is working on a reply...