Showing posts with label writing. Show all posts
Showing posts with label writing. Show all posts

Wednesday, March 21, 2012

Delegates on succes webservice call

Hi All,

I am writing a control where i would like to refer to a method inside my own control, see code below to make the situation clear:

var webRequest = Sys.Net.WebServiceProxy.invoke('Webservice/ImageService.asmx','Hello',false,null,this.WebserviceCallCompleted,this.WebserviceCallFailed,null, 10000);

First i do a webservice call which is working great! As you can see when the call succeeds the function WebserviceCallCompleted is invoked. In this method i would like to set a variable and start the rendering proces again. I do this with:this.Render;

WebserviceCallCompleted:function(result)

{

this._buttonText = result;

this.Render;

}

When i run this code the Render method isn't invoked. any ideas? should i use delegates?

Thanks in advance!

Regards,

To Resolve the this keyword use Function.createDelegate. Like:

var successHandler = Function.createDelegate(this, this.WebserviceCallCompleted);

var webRequest = Sys.Net.WebServiceProxy.invoke('Webservice/ImageService.asmx','Hello',false,null,successHandler,this.WebserviceCallFailed,null, 10000);


Hi KaziManzurRashid,

Thanks for your reply. I implemented your solution but it isn't working (yet) below you see what i have done:

InvokeWebservice:function()

{

var _completeHandler = Function.createDelegate(this,this.WebserviceCallCompleted);var webRequest = Sys.Net.WebServiceProxy.invoke('Webservice/ImageService.asmx','Hello',false, {"test":$get('txtfld1').value}, _completeHandler,this.WebserviceCallFailed,null, 10000);

}

,

WebserviceCallCompleted:function(result)

{

this.Render;

}

The WebserviceCallCompleted method is invoked so the delegate is implemented right. When i take a closer look at the this instance is see that 'this' is representing the right control and it contains a Render method but it still isn't invoked. Any idea?

Regards,


I could not find any reason the Render is not get executed, may be you should put this.Render() instead of this.Render.


hi KaziManzurRashid,

Very stupid but thats the trick i changed this.Render in this.Render() and it works. Probably there is a difference when you refer to a method when creating a delegate and when refering directly to it. I feel a little stupid! Thanks for your time and solutionBig Smile

Regards,

Define itemTemplate for Reorderlist at runtime

Hi,

I am able to get the reorderlist control to work my supplying a datasource and writing the markup for the itemTemplate.

How do i go about setting the itemTemplate at runtime depending on the datasource?

I tried programatically creating ReorderListItems, and collections but nothing got rendered.

I see that the ReorderList has an itemTemplate property, will this help?

OK. I have figured it out how to do it by creating a class that implements the ITemplate interface.

The problem i have now is i am using the reorderlist control within the accordian control.

For example i have a menu with 3 selections. This is controlled by the accordian.

Within the each accordian pane, i create a reorderlist, therefore there are 3 reorderlists, one within each accordian pane. This works fine, and i am able to reorder the items in the list. However, it seems that when i try to move items in the 2nd/3rd pane, they all disappear into the 1st pane. Is this because even though it looks like the accordian is shrinking and expanding, the actual working area for the reorder list is already defined, hence when pane 1 is minimised with pane 2 open, pane 2 reorderlist is actually already ontop of pane 1 reorder list??

I hope the above makes sense.