繁体   English   中英

单击按钮时确认框的C#

[英]C# for Confirm box when click on the button

净MVC3。以下是我的看法,

      @using (Html.BeginForm("InsertDetails", "Home"))
      {
         <h2 class="filter">Associate Details</h2>
     <fieldset class="fs">
     @foreach (var item in Model.lstTravelReadyEntities)
       {   
     <label class="Detail1" ><b>Associate Id : </b><input type="text" name="Aid" style="border-color:White;" value=@item.Var_AssoId ></label>
     <label class="Detail1"><b>Vertical :</b><input type="text" name="vertical" style="border-color:White;" value=@item.Var_Vertical ></label>
     <label class="Detail1"><b>Visa ValidFrom :</b><input type="text" name="vvf" style="border-color:White;" value=@item.Dt_VisaValidFrom > </label><br /><br />

     <label class="Detail2"><b>Associate Name :</b><input type="text" name="AsName" style="border-color:White;" value=@item.Var_AssociateName ></label>
     <label class="Detail2"><b>Account Name :</b><input type="text" name="Acname" style="border-color:White;" value=@item.Var_AccountName ></label>
     <label class="Detail2"><b>Visa ValidDate :</b><input type="text" name="vvt" style="border-color:White;" value=@item.Dt_VisaValidTill ></label><br /><br />

     <label class="Detail3"><b>Grade HR :</b><input type="text" name="gh" style="border-color:White;" value=@item.Var_Grade ></label>
     <label class="Detail3"><b>Project Name :</b><input type="text" name="Projname" style="border-color:White;" value=@item.Var_Project_Desc ></label><br />                   
     <label class="Detail3" style="visibility:hidden"><b>geo :</b><input type="text" name="geo" style="border-color:White;" value=@item.Var_Geo ></label><br />          
          }
         <h2> Response Details</h2><br />
         Supervisor Response :<input type="radio" class="radi" 
           name="radio" value="yes" onclick="javascript:Getfunc(this.value);">Yes
          <input type="radio" name="radio" value="no" 
           onclick="javascript:Getfunc(this.value)">No
           <div id="es"></div>
           <input type="submit" id="insert" value="Submit" name="Submit"/>
           </fieldset>
               }

还有我下面的控制器

          [AcceptVerbs(HttpVerbs.Post)]
    public string InsertDetails(FormCollection collection)
    {           
        TravelReadyModel oTravelReadyModel = new TravelReadyModel();
        string supervisorip =collection.Get("radio");
        int id = Convert.ToInt32(collection.Get("Aid"));
        string vertical = collection.Get("vertical");
        DateTime validfrom = Convert.ToDateTime(collection.Get("vvf"));
        string account = collection.Get("Acname");
        DateTime validtill = Convert.ToDateTime(collection.Get("vvt"));
        string grade = collection.Get("gh");
        string projectname = collection.Get("Projname");
        DateTime tdate = Convert.ToDateTime(collection.Get("date"));
        int commentid = 5;
        string comment = collection.Get("comment");
        string geo = collection.Get("geo");
        oTravelReadyModel.InsertTravelDetails(tdate, id, vertical, account, geo, validfrom, validtill, grade, projectname, supervisorip, commentid, comment);
        return "true";
    }        

插入记录后,我想在同一页面中获取内部文本。要返回同一页面中的成功消息,我需要返回什么?

在“提交”按钮中使用普通的旧javascript,因此视图中的代码如下所示:

....
<input type="submit" id="insert" value="Submit" name="Submit" 
    onclick="return confirm('Are you sure you want to submit')">
</fieldset>
}

注意:还有其他方法可以执行此操作,但这是最快,最简单的方法,也是最脏的方法。

另请参阅:

如何使用ASP.NET添加客户端(JavaScript)确认消息框?

有关如何将其添加为验证。

可以使用JQuery Submit事件。 请查看以下链接,了解N种方法。

http://api.jquery.com/submit/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM