ASPX page and ascx User Control
1. Create an ascx Control
2. Add attributes to ascx
3. Drag the control into Aspx.
4. In the aspxCodeAccess properties by Control ID
For example, <uc3: left_repassword id = "left_repassword1" runat ="Server"/>
Left_repassword1.highlight = value;
It also applies to accessing ascx on the master page.
-----------------------------------------------------------------------
ASP . Net access the masterpage controls, properties, methods, and methods of calling the content page on the master page
The methods used to access the master page (master) controls, properties, methods, and calling the content page (aspx) in ASP. NET are summarized for your reference:
First, you must use the mastertye command on the Content Page to implement a strongly typed master page, that is, add the following command in the settings of the Content Page code Header
<% @ Mastertype virtualpath = "~ /Master/menuelement. Master "%>
Virtualpath sets the URL address of the master page.
1. Obtain the control reference on the master page.
Sample Code
/// <Summary>
/// Obtain a reference to a Treeview control on the dashboard page
/// </Summary>
Public Treeview elementstructuretree
{
Get
{
Return tvelementstructure;
}
Set
{
Tvelementstructure = value;
}
}
As shown in the code above, a public attribute elementstructuretree is defined on the master page, which references the tvelementstructure control on the master page, then, on the content page, you can reference the tvelementstructure control in the master page by using the public attribute master (an attribute of the core object page), as follows:
Treeview TV = Master. elementstructuretree;
2. Access master page properties.
There are generally three types of attributes on the master page: value type, class type, and control type. The above "Get Master Page Control Reference" is actually an access control type attribute, the other two types of attributes can be accessed in the same way.
3. Call the master PAGE method.
The public methods defined on the master page can be directly called by the master.
4. Call the Content Page Method on the master page.
Define delegation on the master page:
Public Delegate void elementselectedchangehandler ();
Instantiate the delegate in the master page (it is also an attribute ):
Public elementselectedchangehandler elementselectedchange {private get; set ;}
Call the delegate as needed on the master page:
If (elementselectedchange! = NULL)
{
Elementselectedchange ();
}
On the content page, specify a method that matches the delegate signature:
Master. elementselectedchange = This. elementselectedchange;
5. The autoeventwireup attribute of the master page must be set to "true" to automatically trigger all events of the control on the master page.