Install superlib ComponentsProgramEncountered a few troubles. Mainly to complete several functions: In virsual studio. to guide the user to complete some simple work; To virsual studio. add a new tab in the net 2003 toolbox and register the web form control in the superlib component library.
About adding a new tab to the virsual Studio. NET 2003 toolbox and registering the web form control in the superlib component library, I posted an article a few days ago.Article:
Http://www.cnblogs.com/haozidong/articles/52432.htm
During the Wizard, I encountered a little trouble. Today I finally finished the custom wizard and shared it out.
Post a reference article in English. It's too long to translate.
Http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/dv_vstechart/html/customwebwiz. asp
Http://msdn.microsoft.com/library/en-us/dv_vstechart/html/customprojectwiz.asp
it is enough to add a web form wizard. I am talking about how to add a custom C # ASP. NET Web Application Wizard, about modifying default. JS file.
the General C # ASP. in the net Web Application Wizard, replace the standard webform1 with our own (others such as web. config can be replaced directly), because our webform1 may need different namespace references, may need to register tagprefix, and may already have several of our own standard controls.
when the existing wizard adds webform1.apsx to the project, a webform1.aspx is automatically generated. CS file, so although we have added the custom webform1.aspx according to the practices in the above article. CS, modified templates. INF, modified default. JS to delete the automatically generated webform1.aspx. CS and so on. It seems OK, right?
but every time you use a new Wizard to generate a project, when you add webform1.aspx. CS automatically, a message indicating that webform1.aspx. CS already exists will be displayed!
I wanted to add some debugging in default. js. If alert is used, the result will not work. The Wizard execution environment does not support the alert command. What should I do? Haha, use FileSystemObject for OK:
var file = FSO. opentextfile ("C: \ aaa.txt", 8, true);
FSO. writeline ("aaaaaa");
In this way, you can write the debugging information in the text file (You may be prompted that you do not have the permission, so you don't have to worry about it. It will be fine for the next operation ).
In the WEB Project, the file paths are all http: // localhost/webapplication1/webform1.aspx. in this format, the savedeletefile function in the above article uses FileSystemObject to delete and automatically add webform1.aspx. the CS file won't work. What should I do?
We need to do this:
If (strtarget = "webform1.aspx ")
{
If (projfile! = NULL ){
VaR item = doesfileexistinproj (projfile, "webform1.aspx. cs ");
If (item! = NULL)
Item. Delete ();
}
}
Note that in the project structure, webform1.aspx. CS gets the next level in webform1.aspx, which is the subitem of webform1.aspx.
OK?
No. Although the automatic webform1.aspx. CS file can be deleted here, after the Wizard is complete, webform1.aspx. CS is not hidden and the corresponding resx file is gone. What's the problem? Originally, resx is automatically generated when webform1.aspx is enabled in the development environment, while webform1.aspx. CS is also hidden at this time. Execute the preceding command to delete the file.CodeBefore webform1.aspx is enabled in the development environment, you must open webform1.aspx in the development environment after adding your own webform1.aspx. CS.
Custom addfilestoproject function:
Function addfilestoproject (oproj, strprojectname, strprojectpath, inffile, additemfile)
{
Try
{
DTE. suppressui = false;
VaR projitems;
If (additemfile)
Projitems = oproj;
Else
Projitems = oproj. projectitems;
VaR strtemplatepath = wizard. findsymbol ("templates_path ");
VaR strtpl = "";
VaR strname = "";
// If (not a WEB Project)
If (strprojectpath. charat (strprojectpath. Length-1 )! = "\\")
Strprojectpath + = "\\";
VaR strtextstream = inffile. openastextstream (1,-2 );
While (! Strtextstream. atendofstream)
{
Strtpl = strtextstream. Readline ();
If (strtpl! = "")
{
Strname = strtpl;
VaR strtarget = "";
VaR strfile = "";
If (! Additemfile)
{
Strtarget = getcsharptargetname (strname, strprojectname );
}
Else
{
Strtarget = wizard. findsymbol ("item_name ");
}
VaR FSO;
FSO = new activexobject ("scripting. FileSystemObject ");
VaR temporaryfolder = 2;
VaR tfolder = FSO. getspecialfolder (temporaryfolder );
VaR strtempfolder = FSO. getabsolutepathname (tfolder. Path );
VaR strfile = strtempfolder + "\" + FSO. gettempname ();
VaR strclassname = strtarget. Split (".");
Wizard. addsymbol ("safe_class_name", strclassname [0]);
Wizard. addsymbol ("safe_item_name", strclassname [0]);
VaR strtemplate = strtemplatepath + "\" + strtpl;
VaR bcopyonly = false;
VaR strext = strtpl. substr (strtpl. lastindexof ("."));
If (strext = ". BMP "| strext = ". ICO "| strext = ". GIF "| strext = ". rtf "| strext = ". CSS ")
Bcopyonly = true;
Wizard. rendertemplate (strtemplate, strfile, bcopyonly, true );
VaR projfile = projitems. addfromtemplate (strfile, strtarget );
Safedeletefile (FSO, strfile );
If (projfile)
Setfileproperties (projfile, strname );
If (strtarget = "webform1.aspx. cs ")
{
VaR item = doesfileexistinproj (oproj, "webform1.aspx ");
If (item! = NULL ){
VaR window = item. Open (vsviewkindprimary );
Window. Visible = true;
}
}
If (strtarget = "webform1.aspx ")
{
If (projfile! = NULL ){
VaR item = doesfileexistinproj (projfile, "webform1.aspx. cs ");
If (item! = NULL)
Item. Delete ();
}
}
}
}
Strtextstream. Close ();
}
Catch (E)
{
Strtextstream. Close ();
Throw E;
}
}
Standard addfilestocsharpproject Function
Function addfilestocsharpproject (oproj, strprojectname, strprojectpath, inffile, additemfile)
{
Try
{
DTE. suppressui = false;
VaR projitems;
If (additemfile)
Projitems = oproj;
Else
Projitems = oproj. projectitems;
VaR strtemplatepath = wizard. findsymbol ("templates_path ");
VaR strtpl = "";
VaR strname = "";
// If (not a WEB Project)
If (strprojectpath. charat (strprojectpath. Length-1 )! = "\\")
Strprojectpath + = "\\";
var strtextstream = inffile. openastextstream (1,-2);
while (! Strtextstream. atendofstream)
{< br> strtpl = strtextstream. Readline ();
If (strtpl! = "")
{< br> strname = strtpl;
var strtarget = "";
var strfile = "";
If (! Additemfile)
{< br> strtarget = getcsharptargetname (strname, strprojectname);
}< br> else
{< br> strtarget = wizard. findsymbol ("item_name");
}
VaR FSO;
FSO = new activexobject ("scripting. FileSystemObject ");
VaR temporaryfolder = 2;
VaR tfolder = FSO. getspecialfolder (temporaryfolder );
VaR strtempfolder = FSO. getabsolutepathname (tfolder. Path );
VaR strfile = strtempfolder + "\" + FSO. gettempname ();
VaR strclassname = strtarget. Split (".");
Wizard. addsymbol ("safe_class_name", strclassname [0]);
Wizard. addsymbol ("safe_item_name", strclassname [0]);
VaR strtemplate = strtemplatepath + "\" + strtpl;
VaR bcopyonly = false;
VaR strext = strtpl. substr (strtpl. lastindexof ("."));
If (strext = ". BMP "| strext = ". ICO "| strext = ". GIF "| strext = ". rtf "| strext = ". CSS ")
Bcopyonly = true;
Wizard. rendertemplate (strtemplate, strfile, bcopyonly, true );
VaR projfile = projitems. addfromtemplate (strfile, strtarget );
Safedeletefile (FSO, strfile );
If (projfile)
Setfileproperties (projfile, strname );
VaR bopen = false;
If (additemfile)
Bopen = true;
Else if (doopenfile (strtarget ))
Bopen = true;
If (bopen)
{
VaR window = projfile. Open (vsviewkindprimary );
Window. Visible = true;
}
}
}
Strtextstream. Close ();
}
Catch (E)
{
Strtextstream. Close ();
Throw E;
}
}
Modifications to other related parts are not listed.