2017-07-25 61 views
1

我在我的视图div上传PartialView。无效的正则表达式标志错误部分视图

这里是代码

<div id="right2" style=" border-style: solid; border-color: #1d69b4; border-radius: 10px;"> @Html.Partial("CalendarDefault") </div>

而且通过按钮,我需要一个PartialView更改为另一个

这里是按钮的代码

<button class="filled-button" onclick="myFunction()" style="background: #72c367">New Appointment</button>

而对于负载

JS代码
<script> 
function myFunction() { 
    $("#right2").load(@Url.Action("SheduleNewAppointment","Calendar")); 
} 
</script> 

但我有以下错误

myFunction is not defined at HTMLButtonElement.onclick (Index:125) Uncaught SyntaxError: Invalid regular expression flags

我怎样才能解决呢?

+0

您需要定义的“SheduleNewAppointment”中的Controler –

回答

2

这对我来说例如工作:

下面是我在CSHTML文件创建的代码:

<script> 
     $('#getDetails') 
      .click(function() { 
       $('#detailsPlace').load('@Url.Action("GetDetails", "Home")'); 
      }); 
    </script> 

<table class="table"> 
    @foreach (var item in Model) 
    { 
     <tr> 
      <td> 
       <a href="#" id="getDetails">@Html.DisplayFor(modelItem => item.Description)</a> 
      </td> 
     </tr> 
    } 
</table> 

<div id="detailsPlace"></div> 

/主页/ GetDetails被解释为正则表达式,使用“首页“作为模式和”GetDetails“作为标志。这是一个无效的正则表达式,因此是错误。

这是我的位指示里面的代码:

[HttpGet] 
    public ActionResult Index() 
    { 
     ReferenceRepository test = new ReferenceRepository(); 

     var response = test.GetParts("A"); 
     return View(response); 
    } 
public ActionResult GetDetails() 
    { 
     return PartialView(); 
    } 
相关问题