熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

如何制作Asp.Net界面模板

2022-06-13   來源: .NET編程 

  基礎知識

  C:\Program Files\Microsoft Visual Studio NET \VC#\DesignerTemplates\

  其下的NewWebFormCodecs文件是默認的新AspNet頁面的後台代碼文件;

  C:\Program Files\Microsoft Visual Studio NET \VC#\VC#Wizards\CSharpAddWebFormWiz

  其下的\Scripts\\defaultjs文件定義了基本的針對*aspx頁面的腳本操作;

  其下的\Templates\\WebFormaspx文件定義新AspNet頁面的*aspx文件;

  其下的\Templates\\Templatesinf文件指向了WebFormaspx文件;

  C:\Program Files\Microsoft Visual Studio NET \VC#\CSharpProjectItems\WebProjectItems\UI

  其下的uivsdir文件定義了模板向導的基本信息;

  制作過程 

  建立VC#文件夾其內部結構如下:

  VC#\CSharpProjectItems \WebProjectItems\Itabby界面模板\

  ItabbyAddCommonFormWizvsz內容如下

  VSWIZARD
                                                  Wizard=VsWizardVsWizardEngine
                                                  Param=WIZARD_NAME = ItabbyAddCommonFormWiz
                                                  Param=WIZARD_UI = FALSE
                                                  Param=PROJECT_TYPE = CSPROJ                                

  uivsdir內容如下

  ItabbyAddCommonFormWizvsz|{FAEECFdBFBCFEFBC}|Itabby通用模板||#|{FAEECFdBFBCFEFBC}|||ItabbyCommonFormaspx

  VC#\DesignerTemplates\\

  NewWebFormCodecs修改微軟NewWebFormCodecs而成

  VC#\VC#Wizards\ItabbyAddCommonFormWiz\Scripts\\

  defaultjs修改微軟defaultjs而成

  VC#\VC#Wizards\ItabbyAddCommonFormWiz\Templates\\

  ItabbyWebFormaspx 修改微軟WebFormaspx而成

  Templatesinf              內容如下

  ItabbyWebFormaspx

  分析說明

  CSharpProjectItems
                    webProjectItems
                          Itabby界面模板
                                   ItabbyAddCommonFormWizvsz
                                   內容:
                                   VSWIZARD
                                   Wizard=VsWizardVsWizardEngine
                                   Param=WIZARD_NAME = ItabbyAddCommonFormWiz
                                   Param=WIZARD_UI = FALSE
                                   Param=PROJECT_TYPE = CSPROJ
                                   說明:上述代碼修改自微軟:\CSharpProjectItems\WCSharpAddWebFormWizvsz中:
                                   VSWIZARD
                                   Wizard=VsWizardVsWizardEngine
                                   Param=WIZARD_NAME = CSharpAddWebFormWiz
                                   Param=WIZARD_UI = FALSE
                                   Param=PROJECT_TYPE = CSPROJ
                        uivsdir
                        內容:
                        ItabbyAddCommonFormWizvsz|{FAEECFdBFBCFEFBC}|Itabby通用模板||#|{FAEECFdBFBCFEFBC}|||ItabbyCommonFormaspx
                        說明:
                        上述代碼修改自微軟:\CSharpProjectItems\WebProjectItems\UI\uivsdir中:
                       \\CSharpAddWebFormWizvsz|{FAEECFdBFBCFEFBC}|#||#|{FAEECFdBFBCFEFBC}|||WebFormaspx
        DesignerTemplates
                 
                         NewWebFormCodecs
                         內容:
                         $NAMESPACE$        //微軟自動處理
                         $CLASSNAME$        //微軟自動處理
        VC#Wizards
                  ItabbyAddCommonFormWiz
                             Scripts
                                       
                                                defaultjs
                                                內容:

  // (c) Microsoft Corporation
  function AddDefaultServerScriptToWizard(selProj)
  {
   wizardAddSymbol(DEFAULT_SERVER_SCRIPT JavaScript);
  }

  function AddDefaultClientScriptToWizard(selProj)
  {
      var prjScriptLang = selProjProperties(DefaultClientScript)Value;
      // = JScript
      // = VBScript
      if(prjScriptLang == )
      {
   wizardAddSymbol(DEFAULT_CLIENT_SCRIPT JavaScript);
      }
      else
      {
   wizardAddSymbol(DEFAULT_CLIENT_SCRIPT VBScript);
      }
  }

  function AddDefaultDefaultHTMLPageLayoutToWizard(selProj)
  {
      var prjPageLayout = selProjProperties(DefaultHTMLPageLayout)Value;
      // = FlowLayout
      // = GridLayout
      if(prjPageLayout == )
      {
   wizardAddSymbol(DEFAULT_HTML_LAYOUT FlowLayout);
      }
      else
      {
   wizardAddSymbol(DEFAULT_HTML_LAYOUT GridLayout);
      }
  }

  function OnFinish(selProj selObj)
  {
      var oldSuppressUIValue = true;
   try
   {
    oldSuppressUIValue = dteSuppressUI;
    var strProjectName = wizardFindSymbol(PROJECT_NAME);
    var strSafeProjectName = CreateSafeName(strProjectName);
    wizardAddSymbol(SAFE_PROJECT_NAME strSafeProjectName);
    SetTargetFullPath(selObj);
    var strProjectPath  = wizardFindSymbol(TARGET_FULLPATH);
    var strTemplatePath  = wizardFindSymbol(TEMPLATES_PATH);

  //用戶自定義代碼開始
    var strPaths = strProjectPathsplit(\\);
                  var curResPath = ;
    var bFindModules = false;
    for(index = strPathslength;index>=;index)
    {
     if(strPaths[index]==modules)
     {
      bFindModules = true;
      break;
     }
     curResPath += /;
    }
    if(bFindModules==false)
     curResPath = ;
    var curJsPath = curResPath + Jscript/commonjs;
    var curCssPath = curResPath + style/commoncss;
    var curImgPath = curResPath + images
    var curctlPath = curResPath + Jscript/controlpaneljs    
    wizardAddSymbol(ITABBY_JS_SRC curJsPath);
    wizardAddSymbol(ITABBY_CSS_SRC curCssPath);
    wizardAddSymbol(ITABBY_IMG_SRC curImgPath);
    wizardAddSymbol(ITABBY_CTL_SRC curctlPath);
    //用戶自定義代碼結束

  var strTpl = ;
    var strName = ;
    var InfFile = CreateInfFile();
    
    // add the default project props for the aspx file before we
    // render it
    AddDefaultServerScriptToWizard(selProj);
    AddDefaultClientScriptToWizard(selProj);
    AddDefaultTargetSchemaToWizard(selProj);
    AddDefaultDefaultHTMLPageLayoutToWizard(selProj);
    // render our file
    AddFilesToCSharpProject(selObj strProjectName strProjectPath InfFile true);
    AddReferencesForWebForm(selProj);
   }
   catch(e)
   {
    if( edescriptionlength > )
     SetErrorInfo(e);
    return enumber;
   }
      finally
      {
    dteSuppressUI = oldSuppressUIValue;
    if( InfFile )
     InfFileDelete();
      }
  }

  function SetFileProperties(oFileItem strFileName)
  {
      if(strFileName == WebFormaspx)
      {
   oFileItemProperties(SubType)Value = Form;
      }
  }

  說明:上述修改自微軟:\VC#\VC#Wizards\CSharpAddWebFormWiz\Scripts\\defaultjs

  Templates
                 
                       ItabbyWebFormaspx
                       內容:
  <%@ Page language=c# Codebehind=$FILENAME$cs AutoEventWireup=false Inherits=$INHERITS$ %>//微軟自動處理
  <!DOCTYPE HTML PUBLIC //WC//DTD HTML Transitional//EN >
  <html>
    <head>
      <title>平紋科技</title>
      <meta content=Microsoft Visual Studio NET name=GENERATOR>
      <meta content=C# name=CODE_LANGUAGE>
      <meta content=JavaScript name=vs_defaultClientScript>
      <meta content= name=vs_targetSchema>
      <meta content=平紋公司科技服務生活信息創造價值 name=keywords>
      <META httpequiv=ContentType content=text/html; charset=gb>
      <meta name=vs_defaultClientScript content=[!output DEFAULT_CLIENT_SCRIPT]>    //微軟自動處理
      <meta name=vs_targetSchema content=[!output DEFAULT_TARGET_SCHEMA]>        //微軟自動處理
      <LINK [!output _fcksavedurl=[!output ITABBY_CSS_SRC] type=text/css rel=stylesheet>      //用戶自定義變量
      <script src=[!output ITABBY_JS_SRC]></script>                              //用戶自定義變量
    </head>
            

  Templatesinf
                 內容:
                 ItabbyWebFormaspx
                 說明上述代碼修改自微軟:VC#Wizards\CSharpAddWebFormWiz\Templates\\Templatesinf:
                 WebFormaspx

  模板內容

  模板的定制主要以修改\VC#\VC#Wizards\ItabbyAddCommonFormWiz\Templates\ItabbyWebFormaspx和修改VC#\DesignerTemplates\\NewWebFormCodecs為主實現不同的界面風格和代碼邏輯

  \VC#\VC#Wizards\ItabbyAddCommonFormWiz\Scripts\\defaultjs主要實現與aspx頁面的交互如相對路徑的制定自動替換等操作;

  \VC#\CSharpProjectItems\WebProjectItems\Itabby界面模板\ItabbyAddCommonFormWizvsz和VC#\CSharpProjectItems\WebProjectItems\Itabby界面模板\uivsdir主要實現了與集成開發環境的向導交互


From:http://tw.wingwit.com/Article/program/net/201311/12106.html
  • 上一篇文章:

  • 下一篇文章:
  • 推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.