Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 视图没有';无法从控制器返回_C#_Jquery_Ajax_Asp.net Mvc - Fatal编程技术网

C# 视图没有';无法从控制器返回

C# 视图没有';无法从控制器返回,c#,jquery,ajax,asp.net-mvc,C#,Jquery,Ajax,Asp.net Mvc,我想通过onclick函数将数据传送到下一页。所有数据都通过给定参数携带,但它不会从控制器返回视图。请帮帮我。我被困在这里两天这是我的学校项目 单击按钮: <div class="row"> <div class="col-sm-4"></div> <button class='btn bg-blue next' onclick="checkamt(@Model.TotalAmt)">Next</button> <

我想通过onclick函数将数据传送到下一页。所有数据都通过给定参数携带,但它不会从控制器返回视图。请帮帮我。我被困在这里两天这是我的学校项目

单击按钮:

<div class="row">
    <div class="col-sm-4"></div>
    <button class='btn bg-blue next' onclick="checkamt(@Model.TotalAmt)">Next</button>
</div>
阿贾克斯:

功能检查金额(e){
var amount=@ViewBag.CurrentAmt;
如果(金额
视图:


您拥有总计@ViewBag.CurrentAmt点数


删除ajax函数并执行此操作

window.location.href = "@Url.Action("ComfirmPay", "Home")" + "?e=" + e + "&taxtype=" + taxtype + "&currentamt=" + currentamt

帖子上的评论解释了为什么你所做的事情不起作用

我认为您不需要ajax调用。您可以按如下方式使用
window.location.href

 function checkamt(e) {
   var amount = @ViewBag.CurrentAmt;
   if (amount < e) {
         window.location.href = 'http://localhost:22822/Home/PayTax';
   }
  else {
        window.location.href = '/Home/ComfirmPay?e='+e+'&taxtype='+taxtype+'&currentamt='+currentamt;
   }  
 }

在ajax调用中添加错误部分,并检查返回的错误。使用ajax时,返回视图不起作用。如何修复它,先生?您可以使用returnPartialView();您在
操作ComfirmPay
中使用任何“方法”,如
get
post
<div class="col-md-9 col-xs-9">
    <p class="text-muted">You have total <b class="text-green">@ViewBag.CurrentAmt</b> points</p>
</div>
window.location.href = "@Url.Action("ComfirmPay", "Home")" + "?e=" + e + "&taxtype=" + taxtype + "&currentamt=" + currentamt
 function checkamt(e) {
   var amount = @ViewBag.CurrentAmt;
   if (amount < e) {
         window.location.href = 'http://localhost:22822/Home/PayTax';
   }
  else {
        window.location.href = '/Home/ComfirmPay?e='+e+'&taxtype='+taxtype+'&currentamt='+currentamt;
   }  
 }
public ActionResult ComfirmPay(string e, string TaxType, string CurrentAmt)
{
  ViewBag.TotalAmt = e;
  ViewBag.CurrentAmt = CurrentAmt;            
  ViewBag.TaxType = TaxType;            
  return View();
}