Web Custom Control UserControl

Source: Internet
Author: User

Two custom controls were made today, and have been done with WPF before, but the feeling is not the same today. The first is to create a Usercontral control interface in the project, drag the required controls to the inside, and then add events to the buttons. Our company's controls are bought by the Dev Express Control group, the personal feeling is very good, many can be more practical and very aspect, the function is very powerful, after all, is the money of things. But a little bad, when adding an event can not simply by double-clicking, sometimes double-click to add code in the background, but do not add the declaration of the event in the Designer.cs designer, it will cause the double-click interface control can not automatically navigate to the background code, so you have to manually add.

These two controls are actually extracted from a large module, because the large module code too much, did not look carefully, copied a lot of useless code. VS can set the security level, Level 4 is the highest, when you declare that the variable is assigned an initial value is not used, or declare that the variable is not assigned to the initial value, will be error, if you want to comment out the error of the hint, it must comment a lot of code, if not comments and compile does not pass, very annoying. Finally, the security level is lowered. A custom control can be displayed and used in the toolbox only if the solution builds successfully. After the code has been modified, the build succeeds, and when the custom control is dragged into the large module, the Times is wrong, the basehttpcommom "is not found, and the custom control appears to be configured in the Web. config file, which is associated with WCF, without a closer look. Other controls can be used, this is not a problem with the configuration file, or the control of the background code itself, had to be commented out on a method to troubleshoot. Finally locked in both banddata () and Initcontral (), the reason is probably that when you drag a custom control (used in design state) It also loads and calls the code in the control, and uses the DesignMode to determine when it is false to invoke the code. This is not possible, but temporarily commented out and then debug another control.

Another control can be dragged to the interface, and the build is successful, and when executed to the constructor of this control, the error "Object not referenced to instance" is designer.cs in the Previously thought that the Designer.cs file is automatically generated by the system will not have a problem, through these several errors, the designer still need to be manually maintained. The declaration of this control is added to the control's Designer.cs file and can be run after instantiation.

Called in a large module is actually very simple, the custom control and the normal control, the code is written in the background of the custom control, directly to the interface can be used, of course, if assigned to it also need to use the constructor to pass parameters or instantiation of the properties assigned to the value. A custom control is a class, a control class, which, when used, can get its internal methods and properties. Tomorrow Saturday also to work overtime, the large module of redundant code deleted, and then add the new control and the existing event code to get the morning, hey, bitter programmer.

Web Custom Control UserControl

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.