Ian (Fluxtah) Warwick's blog RSS 2.0
# Friday, October 03, 2008

After creating a rough guide to Ajax Snippets video it brought a few things to light, one thing was the awkwardness of having to define callback functions in a SnippetCallback and then having to write them out in the page that hosts the snippet.

I added a feature that allows the developer to select an option from the SnippetCallback controls action list that will copy some javascript function stubs into the clipboard based on the controls settings.

 

The relay snippets example will copy the following into the clipboard

[code:js]
function beforeRelayFields(){
}
function relayFieldsSuccess(result){
}
function relayFieldsFailed(error){
}
[/code]

This may have been an overkill feature but still its good for forgetful people like me that could do with some extra help.

Friday, October 03, 2008 4:00:00 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -

Whilst working on Ajax Snippets I wanted to provide an option for the user in a DesignerActionList to copy some javascript function stubs to the clipboard, at first I was stumped, I have worked with clipboard data before but I could not remember how to do it let alone the environment was giving me doubts to wether the answer was the same as working with winforms.

Like winforms you can get at the clipboard via the not suprisingly named Clipboard class.

 

[code:c#]
    public class MyDesigner : ControlDesigner
    { 
        public override DesignerActionListCollection ActionLists
        {
            get
            {
                DesignerActionListCollection actionLists = new DesignerActionListCollection();
                actionLists.AddRange(base.ActionLists);
               
                actionLists.Add(new MyDesignerActionList(this));
                return actionLists;
            }
        }
    }

    public class MyDesignerActionList : DesignerActionList
    {
        MyDesigner _Designer;
        DesignerActionItemCollection _Items;
        public MyDesignerActionList(MyDesigner designer) : base(designer.Component)
        {
            _Designer = designer;
        }

        public void SetClipboard()
        {
            Clipboard.SetDataObject("Hello World");
        }
        public override DesignerActionItemCollection GetSortedActionItems()
        {
            if (_Items == null)
            {
                _Items = new DesignerActionItemCollection();

                _Items.Add(new DesignerActionMethodItem(this, "SetClipboard", "Set clipboard"));
            }

            return _Items;
        }
    }
[/code]

Friday, October 03, 2008 3:10:00 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -

Archive
<October 2008>
SunMonTueWedThuFriSat
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Ian Warwick
Sign In
Statistics
Total Posts: 33
This Year: 0
This Month: 0
This Week: 0
Comments: 4
Themes
Pick a theme:
All Content © 2012, Ian Warwick
DasBlog theme 'Business' created by Christoph De Baene (delarou)