Development of asp.net custom controls (asp.net study note 3)

Source: Internet
Author: User


In the previous chapter, we wrote one of the simplest custom controls. This time, let us leave the theory behind and develop a practical custom control: a menu that allows you to set permissions.
In this project, we will not use any unlearned theoretical knowledge. Users only need to have basic DHTML knowledge. As you know, server controls are nothing more than HTML and Javascript encapsulation. As for other techniques, we will gradually introduce and apply them in the future to produce commercial controls.
The idea of making this control is simple: first, use DHTML to write a menu, then extract the attributes, and then encapsulate the script and HTML display code, at last, rewrite the Render method as a parameter. You see, it's that simple.
If you do not want to read the code through the browser (it is really annoying), you can download the source code of this project from the following address, including the source code of this custom control and various test files: different data sources and permission settings.
Http://user1.7host.com/cashtsao//CashMenu0110.zip
 
First, declare an enumeration type MainMenuAlign in the namespace CashControls:
Public enum MainMenuAlign
{
/// <Summary>
/// Left
/// </Summary>
Left = 0,
/// <Summary>
/// Intermediate
/// </Summary>
Center = 1,
/// <Summary>
/// Right
/// </Summary>
Right = 2
}
Then declare the class CashMenu inherited from WebControls and declare the following variables and attributes:
Variable:
Private System. Web. HttpContext contextObject;
Private System. Xml. XmlDocument oXmlDoc = new XmlDocument ();

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.