Showing posts with label elements. Show all posts
Showing posts with label elements. Show all posts

Wednesday, March 28, 2012

dynamic html production to call ajax post via javascript

I am maintaining a page that creates html (not server controls) elements dynamically and when one changes I need to call the ajax postback. Is that possible? The page that is created can't know ahead of time that it will need to post through ajax....

So long as you add a client-side Event handler to your html control when you create it, yes, you can wire it up to make asynchronous requests:http://www.mikesdotnetting.com/Article.aspx?ArticleID=40. Note, the methodology outlined in the article doesn't make an ASP.NET Ajax request or postback. It differs in that it only makes a call to the server-side method you want to invoke. This can be better than using ASP.NET Ajax, in that you aren't recreating all the controls on the page.

Dynamic display behaviors for dragDropList

I'm using the drag drop list to allow my users to reposition report elements. The problem that I am having is that different zones have different sizes and we would like our draggable elements to resize to fill the zone in which they are dropped. Unfortunately, the controls are retaining their original sizes when moved to a different drop zone.

Furthermore, we have implemented som cascading styles to allow the controls to change appearance depending on which zone they have been places. This is not working either, the controls always retaing the style of the zone in which they were originally placed.

Any suggestions?

Yeah, you should build a behavior that implements the IDropTarget interface, and assign that behavior to whatever Divs you've go tthat are going to be the drop zones for your parts. The custom behavior you build has to implement this.drop() , among others, and that funciton will define what happens when something's dropped on it. My guess is that you'd build logic into the drop() method that tells the div that was dropped to resize / restyle itself, possibly by just changing the cssClass . Check out this article: http://www.codeproject.com/Ajax/AtlasDragNDrop.asp for more info.