2015-12-11 61 views
-1

這是我的代碼,他在按錯誤輸入...當我按下輸入類型輸入文件打開一個空白窗口

<div class="form-group"> 
      <div class="col-sm-12"> 
       <div id="fileselection" style="margin-bottom:30px"> 
        @using (Html.BeginForm("AdicionarAnexo", "Classe", FormMethod.Post, new { @encoding = "multipart/form-data", @enctype = "multipart/form-data", @id = "AnexoClasseForm", @class = "upload-form" })) 
        { 
         if (ViewBag.Status == null) 
         { 
          <div class="col-sm-5"> 
           <input type="file" name="anexo" id="idAnexo" /> 
          </div> 
          <div class="col-sm-6"> 
           <input type="button" class="btn btn-default" id="adicionarAnexo" value="Incluir anexo" style="margin-top:-10px;" /> 
          </div> 
         } 
        } 
       </div> 
      </div> 
      @*<h4><i class="fa fa-question-circle" data-container="body" data-toggle="popover" data-placement="right" data-content="texto"></i></h4>*@ 
     </div> 

這是輸入,按enter它會打開一個空白屏幕:

enter image description here

回答

0

林加入beginform屬性:

new { onkeydown = "return event.keyCode!=13", 

代碼完成:

@using (Html.BeginForm("AdicionarAnexo", "Classe", FormMethod.Post, new { onkeydown = "return event.keyCode!=13", @encoding = "multipart/form-data", @enctype = "multipart/form-data", @id = "AnexoClasseForm", @class = "upload-form" })) 
相關問題