Set the TagPrefix of the custom Server Control

Source: Internet
Author: User
1. Add the ToolboxData attribute to the server control.

Using System;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. ComponentModel;

Namespace WebControlLibrary1
{
[ToolboxData ("<{0}: WebCustomControl runat = server> </{0}: WebCustomControl>")]
Public class WebCustomControl: System. Web. UI. WebControls. WebControl
{
}
}

The WebCustomControl in ToolboxData is the name of the server control class.

2. Add the following information to the Assembly. cs file of the server control:
Using System. Web. UI
[Assembly: TagPrefix ("WebControlLibrary1", "mycontrol")]
The TagPrefix attribute is located under the System. Web. UI naming control. Therefore, you must reference the System, Web. UI namespace

The prototype of TagPrefix is [assembly: TagPrefix ("namespace", "tagprefix")].

The generated control is dragged to the page to generate the code.
<Mycontrol: WebCustomControl1 runat = "server"> </mycontrol>

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.