You can add your own Smart Tasks to a custom control by inheriting a new class from the base DesignerActionList class. : WebControl « Custom Controls « ASP.NET Tutorial

ASP.NET Tutorial
1. ASP.Net Instroduction
2. Language Basics
3. ASP.net Controls
4. HTML Controls
5. Page Lifecycle
6. Response
7. Collections
8. Validation
9. Development
10. File Directory
11. Sessions
12. Cookie
13. Cache
14. Custom Controls
15. Profile
16. Configuration
17. LINQ
18. ADO.net Database
19. Data Binding
20. Ajax
21. Authentication Authorization
22. I18N
23. Mobile
24. WebPart
25. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
ASP.NET Tutorial » Custom Controls » WebControl 
14. 19. 15. You can add your own Smart Tasks to a custom control by inheriting a new class from the base DesignerActionList class.
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.Design;using System.ComponentModel;
using System.ComponentModel.Design;

namespace myControls
{
    [Designer(typeof(SmartImageDesigner))]
    public class SmartImage : WebControl
    {
        string _imageUrl;
        string _alternateText;
        int _rotation = 0;
        bool _mirror = false;

        public string ImageUrl
        {
            get return _imageUrl; }
            set _imageUrl = value; }
        }

        public string AlternateText
        {
            get return _alternateText; }
            set _alternateText = value; }
        }

        public int Rotation
        {
            get return _rotation; }
            set _rotation = value; }
        }

        public bool Mirror
        {
            get return _mirror; }
            set _mirror = value; }
        }

        protected override HtmlTextWriterTag TagKey
        {
            get
            {
                return HtmlTextWriterTag.Img;
            }
        }        private string GetFilterString()
        {
            string _mirrorValue = "0";
            if (_mirror)
                _mirrorValue = "1";

            return String.Format("progid:DXImageTransform.Microsoft. BasicImage(Rotation={0},Mirror={1})", _rotation, _mirrorValue);
        }

        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            writer.AddStyleAttribute(HtmlTextWriterStyle.Filter, this. GetFilterString());
            writer.AddAttribute(HtmlTextWriterAttribute.Src, _imageUrl);
            writer.AddAttribute(HtmlTextWriterAttribute.Alt, _alternateText);


            base.AddAttributesToRender(writer);
        }
    }

    public class SmartImageDesigner : ControlDesigner
    {
        public override DesignerActionListCollection ActionLists
        {
            get
            {
                DesignerActionListCollection actionLists = new DesignerActionListCollection();
                actionLists.AddRange(base.ActionLists);
                actionLists.Add(new SmartImageActionList(this));
                return actionLists;
            }
        }
    }

    public class SmartImageActionList : DesignerActionList
    {
        private DesignerActionItemCollection items;
        private SmartImageDesigner _parent;

        public SmartImageActionList(SmartImageDesigner parent)
            : base(parent.Component)        {
            _parent = parent;
        }

        public void Rotate()
        {
            TransactedChangeCallback toCall = new TransactedChangeCallback(DoRotate);
            ControlDesigner.InvokeTransactedChange(this.Component, toCall, "Rotate""Rotate image 90 degrees");
        }

        public void Mirror()
        {
            TransactedChangeCallback toCall = new TransactedChangeCallback(DoMirror);
            ControlDesigner.InvokeTransactedChange(this.Component, toCall, "Mirror""Mirror Image");
        }

        public override DesignerActionItemCollection GetSortedActionItems()
        {
            if (items == null)
            {
                items = new DesignerActionItemCollection();
                items.Add(new DesignerActionMethodItem(this, "Rotate""Rotate Image"true));
                items.Add(new DesignerActionMethodItem(this, "Mirror""Mirror Image"true));
            }
            return items;
        }

        public bool DoRotate(object arg)
        {
            SmartImage img = (SmartImage)this.Component;
            img.Rotation += 1;
            if (img.Rotation > 3)
                img.Rotation = 0;
            _parent.UpdateDesignTimeHtml();
            return true;
        }

        public bool DoMirror(object arg)
        {
            SmartImage img = (SmartImage)this.Component;
            img.Mirror = !img.Mirror;
            _parent.UpdateDesignTimeHtml();
            return true;
        }
    }
}
14. 19. WebControl
14. 19. 1. A control that inherits from the WebControl class.
14. 19. 2. Displaying a table of HTML colors.
14. 19. 3. File: DropShadow.cs
14. 19. 4. Specifying the Containing WebControl Tag
14. 19. 5. View State and Control State
14. 19. 6. Supporting Control State
14. 19. 7. Processing Postback Data and Events
14. 19. 8. Handling Postback Events
14. 19. 9. contains the custom pager control.
14. 19. 10. Using Postback Options
14. 19. 11. Working with Control Property Collections
14. 19. 12. Using a ControlBuilder
14. 19. 13. Applying Design-Time Attributes to a Control
14. 19. 14. Creating a Container ControlDesigner
14. 19. 15. You can add your own Smart Tasks to a custom control by inheriting a new class from the base DesignerActionList class.
14. 19. 16. Your own data binding control
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.