Control Development Reading Notes

Source: Internet
Author: User

By default, there is a class class1, but the header does not reference webcontrols. You must add using system. Web. UI. webcontrols;
Inherit the default class1 from webcontrol
In this way, you can write the followingCode:
Protected override void render (system. Web. UI. htmltextwriter writer)
{
Writer. writeline ("Hello World ");
}
Compile and generate
Switch to Web ApplicationProgram, Add reference, project, select the previous project
Here, I have never been able to make it appear in the toolbox (but sometimes, the cause is unknown. If we add an ASP. NET Server Control and webcustomcontrol, a column and an icon will be automatically displayed)

Edit default. aspx
Enter the following code in the header:
<% @ Register Assembly = "classlibrary1" namespace = "classlibrary1" tagprefix = "PC3" %>
Then, enter <: in HTML to intelligently prompt the corresponding content.
The complete input is: <MAID: class1 id = "class11" runat = "server"/>
Knowledge point:
<% @ Register Assembly = "classlibrary1" namespace = "classlibrary1" tagprefix = "PC3" %>:
Register the user control and create an alias.
Tagprefix is the alias of The namespace. If it is changed to other content, it must be reflected in HTML and cannot be empty.
Namespace is the namespace
Assembly is the Assembly, that is, the compiled DLL file name.
Don't be confused next time.
<% @ Register %> valid only for the current page. If valid for the entire project, register it in system. web of Web. config.
<Pages>
<Controls>
<Add Assembly = "classlibrary1" namespace = "classlibrary1" tagprefix = "CC2"/>
</Controls>
</Pages>
If different aliases are also registered on the page, both aliases can be used as follows:
<PC3: class1 id = "class11" runat = "server"/>
<CC2: class1 id = "class12" runat = "server"/>
However, the alias prompts are not so sensitive. It will only take a while.

Page is indirectly inherited from the control class. The default logic of the control rendercontrol () method is to determine the control. if the visible attribute is true, the render () method is called. In addition to generating its own content, the render () method also calls the renderchildren () method to trigger all child controls, sub-control and rendercontrol ()-> render ()-> renderchildren ()
I add the following control to default. aspx:
<PC3: class1 id = "class11" runat = "server" visible = "false"/>
The running result is missing.
Then, change the override content of the control from render to rendercontrol. The result is actually visible = "false" and the effect will not be available.

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.