[英]load another View page only on button click on the same page in mvc3
Below is my View page in which I have called action PromotionalMis and below this view code I have written my action 以下是我的“查看”页面,在其中我将其称为“ PromotionalMis”操作,在此查看代码下方,我已编写了我的操作
@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;">
</div>
<div class="generate">
<input type="submit" name="button" value="Generate" id="btn"/>
</div>
</div>
}
Below is my Action in Home Controller. 以下是我在家庭控制器中的操作。 I want to do things is that whenever I select albumname and song name from dropdownlist and when I will click on button My PromotionalMis view page should be visiblee on the same page
我想做的是,每当我从下拉列表中选择专辑名称和歌曲名称时,以及当我单击按钮时,我的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");
}
}
@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;">
</div>
<div class="generate">
<input type="submit" name="button" value="Generate" id="btnclick"/>
</div>
</div>
}
<div id="filesBody"></div
its working well 它运作良好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.