ASP.net 3.5 control and Component Development Technology series-server control properties (iv)

Source: Internet
Author: User

The

Then defines an editor, in which all of these editor functions are equivalent to a "bridge" that associates the property with a custom form form. The code is as follows:

///<summary>
///get more from this book, see:
///http://blog.csdn.net/ChengKing/archive/2008/08/18/ 2792440.aspx
///</summary>

public class Calculatorselecteditor: System.Drawing.Design.UITypeEditor
{
Public calculatorselecteditor ()
{

}
Public Overr IDE System.Drawing.Design.UITypeEditorEditStyle GetEditStyle
(System.ComponentModel.ITypeDescriptorContext    Context)
{
Return uitypeeditoreditstyle.modal


Public override Object EditValue (System.ComponentModel.ItypeDescriptor
Context Context,system.iserv     Iceprovider provider,object value)
{
IWindowsFormsEditorService service = (iwindowsformseditorservice)
Provider. GetService (typeof (IWindowsFormsEditorService));     

if (service = = null)
{
return null;
The

Formkeyboard form = new Formkeyboard ();

if (service. ShowDialog (form) = = DialogresulT.ok)
{
Object strreturn = Form.strreturnvalue;
return strreturn;   
}

return value;
}
}

The function of this class is to pop up a pattern of the Calculator form form, with the editor function defined in section 4.5.2.2 is almost the same, here is not much to say, if there is no clear place please review the contents of the previous chapters.

Finally, you define the main control code class as follows:

/// <summary>
/// 获得本书更多内容,请看:
/// http://blog.csdn.net/ChengKing/archive/2008/08/18/2792440.aspx
/// </summary>

[DefaultProperty("Money")]
[ToolboxData("<{0}:CalculatorSelectControl
   runat=server></{0}:CalculatorSelectControl>")]
public class CalculatorSelectControl : WebControl
{
   [Bindable(true)]
   [Category("自定义计算机属性")]
   [DefaultValue("")]
   [Localizable(true)]
   [Editor(typeof(CalculatorSelectEditor),typeof(System.Drawing.Design.  UITypeEditor))]
   [Description("请输入金额")]
   public string Money 
   {
     get
     {
       string s = (string)ViewState["Money"];
       return ((s == null) ? "" : s);
     }

     set
     {
       ViewState["Money"] = value;
     }
   }
   //… …
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.