Making server controls in embedding vs.net

xiaoxiao2021-03-06  89

It is very simple to say that it really uses it. Recommended collection. Server controls for embedding VS.NET www.itonline.gd.cn 2003-11-19

Did you have your own ASP.NET Server Control? Is there anything like an ASP.NET DATAGRID control:

1. From Toolbox, automatically produce a bunch of code

2. Right Click looks at the properties, there is a lot of Custom Attribute

3. You can also enter the Template Edit mode to put Dongdong, TEXTBOX in Toolbox to your control.

4. I can even pop up a breege of my dialog to do a huge complex configuration.

I spent a day to see how to do these stuff, although I finally found that I don't need these Features but still share it with you, some Dongdong, you don't want to see it really don't know that it is so simple, just like some things you. After reading the findings, it is so complicated.

Main documentation: (Note URL Retine) MSDN LIB: Enhancing Design-Time Supporthttp: //msdn.microsoft.com/library/default.asp? URL = / Library / En-US / CPGUIDE / HTML / CPCONENCINGDESIGN-TIMESUPPORT.ASP PDC02 Session 407 is like Build ASP.NET Server Control.

msdn documentation straight to the point in the first paragraph says: In the .NET Framework, the work for design-time support is not delegated to a design environment such as Visual Studio .NET but is enabled through a rich built-in design-time architecture.

So the Dongdong you have to do is any vs.Net Add-ON, but directly expand your control.

1. From Toolbox, automatically produce a bunch of code this thing is achieved by adding an Attribute in your Server Control code: (Do not saying attribute programming) [ToolboxData ("<{0}: myControl runat = server > ")] public class mycontrol: system.web.ui.webcontrols.dataGrid // When you take your control to WebForm, it will automatically generate these code. fun.

2. When Right Click looks at the properties, there is a lot of Custom Attribute, such as a property in your control, which is a URL of the XSL File, you can: [Browsable (True), Category ("Data"), DefaultValue ("http: / /MYSERVER/Myapp/myxsl.xsl ";), Description (" Specify Your XSL File URL "), Editor (typeof (System.web.ui.design.xsluRleditor), TypeOf (System.drawing.Design.uityPeEditor)] Public String MyxSLTSRC {...} This, you can see your MyxSLTSRC music in the DATA group of the Properties dialog, and you can specify this value through a dialog box for the XSL URL. 3. You can also enter the Template Edit mode to put Dongdong in Toolbox's TEXTBOX to your control over your control. The rest of the Dongdong is really written. First, you have to tell the control for its old people to do Designer: [Designer ("YourNamespace.Design.myControlDesigner, YourNamespace")] public class mycontrol: system.web.ui.webcontrols.DataGrid // Jelly

Then it really give the elderly to be a Designer: namespace YourNameSpace.Design {public class MyControlDesigner: System.Web.UI.Design.WebControls.DataGridDesigner {// Because control is inherited from the DataGrid, control designer will inherit from DataGridDesigner}} What is this Designer mainly do? You must at least go to a HTML code in the VS.NET IDE in the VS.NET IDE, you can see your old hard work. Main through Override these Methods: public override string getdesigntimehtml () protected override string getemptyDesigntimehtml ()

For example, your control supports Data Binding, you can consider using some Sample Data to display. Or do more work really bind the Data Source specified by Page Developer to display.

Look carefully, you will find how to build an Edit Template. After doing Edit Template, your Right Click your control can enter edit mode. For example, in your control contains a Content Template, you can use the ASP.NET TEXTBOX in Toolbox directly Drag & DROP to Drag & DROP. Relat in it.

4. Even one you can play your own dialog box to do a big complex configuration To achieve this, you have to make more efforts, you have to make a MyControlComponiteTeNTor: System.Web.ui.Design.WebControls.DataGridComponiteTor and tell it myControl elderly please use this Editor: [Editor (typeof (MyControlComponentEditor), typeof (ComponentEditor))] public class myControl: System.Web.UI.WebControls.DataGrid // random example of how to achieve concrete through override methods, their own Check the document 8.

转载请注明原文地址:https://www.9cbs.com/read-106361.html

New Post(0)