问题描述
我有一个预览按钮。点击预览按钮我想显示视图。但是点击按钮我已经传递了两个参数作为查询字符串。但我不想在url中显示这些参数。另一种方式是什么?
Plz帮助我..
我尝试了什么:
函数GetId(tempid){
var ProductId = getParameterByName('productid');
var url =../Template/GetDataForTemplete?TempleteID=+ tempid +& ProductID =+ ProductId;
window.location.href = url;
}
public ActionResult GetDataForTemplete(int templeteIDint ProductID)
{
EventViewModel model = new EventViewModel();
model = GetData(ProductID);
if(TempleteID == 1)
{
返回查看(Templete1,型号);
}
}
I have a preview button. on click of preview button I want to display view. but on clicking button I have pass two parameters as querystring. But I dont want to display that parameters in url. what is another way?
Plz help me..
What I have tried:
function GetId (tempid) {
var ProductId = getParameterByName('productid');
var url = "../Template/GetDataForTemplete?TempleteID=" + tempid + "&ProductID=" +ProductId;
window.location.href = url;
}
public ActionResult GetDataForTemplete(int templeteIDint ProductID)
{
EventViewModel model = new EventViewModel();
model = GetData(ProductID);
if (TempleteID == 1)
{
return View("Templete1", model);
}
}
推荐答案
@using (Html.BeginForm("GetDataForTemplete", "Home", FormMethod.Post, new { id = "myForm" }))
{
<input type="hidden" name="templeteID" id="templeteID" />
<input type="hidden" name="ProductID" id="ProductID" />
<input type="submit" value="Submit" />
}
<script type="text/javascript">
function GetId(tempid) {
// set the form variables to whatever you want
这篇关于如何在按钮单击时使用2个参数重定向到控制器方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!