CSTemplates in almost all over the application, when we useSDKDuring secondary development, we need to be familiar with the process for a long time. Most of the time this process is occupied by annoying searches, such as search templates and search files, you can use the Class View to quickly locate the file where the class is located. However, it is not that convenient to determine the template or class to be modified.CSHere we have done some work for us, but it is not very convenient. Follow the methods below to intuitively find the file to be modified.
InCSInHtmlCodeThe class name and template file path of the template used by the page will be embedded, but it isHtmlThe annotation method is embodied. To determine the information of a module, you also need to view the source file and perform tedious retrieval, here, we only need to make a slight transformation to make these annotations more intuitive at a glance to quickly understand the relevant information of the module.
Let's open\ SRC \ controls \ baseclasses \ templatedwebcontrol. CSAnd\ SRC \ controls \ baseclasses \ skinnedwebcontrol. CSThese two files are the base classes of the system template controls. They both have the following method:
[System. Diagnostics. Conditional ( " Debug " )]
Protected Void Sourcemarker ( Bool Isstart, htmltextwriter writer)
{
If (Isstart)
{
Writer. writeline ( " <! -- Start: {0} --> " , This . GetType ());
If (System. Io. file. exists (httpcontext. Current. server. mappath ( This . Skinpath )))
Writer. writeline ( " <! -- Skin path: {0} --> " , This . Skinpath );
Else If (Skintemplate ! = Null )
Writer. writeline ( " <! -- Inline skin: {0} --> " , True );
Else
Writer. writeline ( " <! -- Skin path: {0} --> " , This . Defaultskinpath );
}
Else
Writer. writeline ("<! -- End: {0} -->",This. GetType ());
}
The purpose of this method is to record the class name and skin path used by the control when the control is output in the debug compiling environment, it is convenient for the client to find and modify the corresponding code through the HTML code. However, HTML annotations are used here, which is inconvenient for searching, so it is more convenient to convert it into HTML hidden labels and display the brakes on the browser as needed. The modification method is as follows:Sourcemarker
[System. Diagnostics. Conditional ( " Debug " )]
Protected Void Sourcemarker ( Bool Isstart, htmltextwriter writer)
{
// Edit by lf
If (Isstart)
{
Writer. writeline ( " <Span style = 'display: none; Background-color: infobackground; 'id = 'classinfo 'name = 'classinfo'> Start: {0} </span> " , This . GetType ());
String Skinpath = Globals. getskinpath () + " /Skins/ " + Skinfilename. trimstart ( ' / ' );
If (System. Io. file. exists (skinpath ))
Writer. writeline ( " <Span style = 'display: none; Background-color: infobackground; 'id = 'skininfo' name = 'skininfo'> skin path: {0} </span> " , Skinpath );
Else
Writer. writeline ( " <Span style = 'display: none; Background-color: infobackground; 'id = 'skininfo' name = 'skininfo'> skin path: {0} </span> " , Globals. applicationpath + " /Themes/default/skins/ " + Skinfilename. trimstart ( ' / ' ));
}
Else
Writer. writeline ( " <Span style = 'display: none; Background-color: infobackground; 'id = 'classinfo 'name = 'classinfo'> end: {0} </span> " , This . GetType ());
}
You can see that it is actually very simple here, just change the corresponding HTML comment to a hidden span tag, and modify the corresponding two class files in this way.
After modifying the above two files, you also need to modify the files required for each page. Here we select \ SRC \ controls \ utility \ footer. CS file, because this script file is used on every page, we can set a switch here to enable it to automatically display and hide the modified label above by clicking.
In the render method of the footer class, set the corresponding writer. the writer method is changed to the following style. In this way, you can click the skin, inskin, and class connections in the footer to display the corresponding debug labels.Footer
# If Debug
Writer. Write ( " & Copy; Copyright 2006 xxxxxx Corporation. All Rights Reserved. <span onclick = 'showdebugobj (\ " Skininfo \ " ) '> Skin </span> <span onclick = 'showdebugobj (\ " Inskininfo \ " ) '> Inskin </span> <span onclick = 'showdebugobj (\ " Classinfo \ " ) '> Class </span> " );
Writer. Write ( @" <Script language = 'javascript '>
Function showdebugobj (n ){
VaR objs = Document. getelementsbyname (N );
If (objs. Length = 0) Alert ('not found: '+ n );
For (I = 0; I <objs. length; I ++ ){
If (objs [I]. style. Display = 'None ')
Objs [I]. style. Display = '';
Else
Objs [I]. style. Display = 'none ';
}
}
</SCRIPT>
" );
# Else
Writer. Write ( " & Copy; Copyright 2006 xxxxxx Corporation. All rights reserved. " );
# Endif
Through the above transformation, we can see three labels in the footer: Skin, inskin, and Class. When we click these three labels, the page displays the Class Name of the corresponding control, skin path and other information, which can quickly locate the resource to be modified during the Second Development of CS, saving a lot of retrieval time. Hope to help you.