加载另一个视图页面,只有在按钮上点击相同的页面在mvc3

本文关键字:mvc3 按钮 另一个 加载 视图 | 更新日期: 2023-09-27 17:50:12

下面是我的View页面,我在其中调用了action PromotionalMis,在这个View代码下面我写了action

@using (Html.BeginForm("PromotionalMis", "Home", FormMethod.Post))
{
    <div class="loginn" style="width:600px;">
       <div class="logintext" style="width:154px;">
          @Html.LabelFor(model => model.SongId, "Song Name")
      </div>
      <div class="mistype">
      <select id="ddlsongs" name="ddlsongs" class="state" required="required">
      </select>
      </div>
    </div>
    <div class="loginn" style="width:600px;">
       <div class="logintext" style="width:154px;">
         &nbsp;
       </div>
    <div class="generate">
       <input type="submit" name="button" value="Generate" id="btn"/> 
    </div>
  </div>  
}

下面是我在Home Controller中的Action。我想做的事情是,每当我从下拉列表中选择专辑名和歌曲名时,当我点击按钮时,我的PromotionalMis视图页面应该在同一页面上可见

   [HttpPost]
    public ActionResult PromotionalMis(string ddlsongs)
    {
        if (Session["user"] != null && Session["user"].ToString() == "MISADMIN")
        {
            if (ddlsongs != "0")
             {                  
                string sSongName = "";
                int iId = Convert.ToInt32(ddlsongs);
                List<CRBT_Promotion> ss = new List<CRBT_Promotion>();
                using (crbt_onwebEntities dbcontext = new crbt_onwebEntities())
                {
                    ss = (from z in dbcontext.CRBT_Promotion where z.id == iId select z).ToList();
                }
                foreach (var ssname in ss)
                {
                    sSongName = ssname.SongName.ToString();
                }
                Session["ss"] = sSongName;
                ViewBag.songformis = sSongName;
            }
            return PartialView("PromotionalMis");  
        }
        else
        {
            return RedirectToAction("LogOn");
        }
    }

加载另一个视图页面,只有在按钮上点击相同的页面在mvc3

 @using (Ajax.BeginForm("ActionName", "Home", new AjaxOptions {HttpMethod="POST", UpdateTargetId = "filesBody" ,InsertionMode = InsertionMode.Replace}))
{
<div class="loginn" style="width:600px;">
<div class="logintext" style="width:154px;">
 @Html.LabelFor(model => model.SongId, "Song Name")
 </div>
 <div class="mistype">
<select id="ddlsongs" name="ddlsongs" class="state" required="required">
</select>
</div>
</div>
<div class="loginn" style="width:600px;">
<div class="logintext" style="width:154px;">
&nbsp;
 </div>
 <div class="generate">
<input type="submit" name="button" value="Generate" id="btnclick"/> 
</div>
</div>  
     }
     <div id="filesBody"></div

运行正常