Compartilhar via


Erro de manipulação em arquivos HTML de Assistente

Quando você criar um assistente com uma interface de usuário, seu projeto inclui arquivos .htm.Use esses arquivos para personalizar seu projeto.See Arquivos HTML para obter mais informações.

Seu projeto deve incluir o tratamento de erro.O código a seguir fornece um exemplo de tal código.

Para manipular erros em HTML

  1. Ao validar os campos, se você chamar um método de validação em uma DLL (que deve ser definidas as informações de erro), telefonar ReportError sem parâmetros.

    function ValidateInput()
    {
       if (!window.external.ValidateFile(HEADER_FILE.value))
       {
          ReportError();
          HEADER_FILE.focus();
          return false;
       }
    }
    
  2. Quando você validar campos, se você validar o campo usando somente o script HTML, telefonar SetErrorInfo primeiro e, em seguida, chame ReportError sem parâmetros.

    function OnWhatever()
    {
       if (!ValidateInput())
          window.external.ReportErrror();
       ....
    }
    
    function ValidateInput()
    {
       .....
    
       if (HEADER_FILE.value == IMPL_FILE.value)
       {
          var L_ErrMsg_Text = "Header and implementation files cannot have the same name.";
          SetErrorInfo(L_ErrMsg_Text);
          bValid = false;
       }
       if (TYPE.value == "")
       {
          var L_ErrMsg4_Text = "Type cannot be blank.";
          SetErrorInfo(L_ErrMsg4_Text);
          bValid = false;
       }
       return bValid;
    }
    
  3. De telefonarReportError parâmetros:

    function ValidateInput()
    {
       if (!IsListed(strType))
       {
          var L_Invalid2_Text = "The variable type should be one of the types listed.";
          window.external.ReportError(L_Invalid2_Text);
          VariableType.focus();
          return false;
       }
    }
    
  4. Se for necessário passar de volta à Novo projeto or Adicionar novo item caixa de diálogo de de retornoVS_E_WIZBACKBUTTONPRESS:

    try
    {
       oCM   = window.external.ProjectObject.CodeModel;
    }
    catch(e)
    {
       var L_NCBError_Text = "Cannot access the Class View information 
    (.ncb) file. Class View information will not be available.";
       window.external.ReportError(L_NCBError_Text);
       return VS_E_WIZARDBACKBUTTONPRESS;
    

Consulte também

Conceitos

Arquivos criados para O Assistente

O Assistente de personalização