~/ equivalent in javascript

后端 未结 12 1966
萌比男神i
萌比男神i 2020-12-12 19:11

Any smart way of doing a \"root\" based path referencing in JavaScript, just the way we have ~/ in ASP.NET?

12条回答
  •  暖寄归人
    2020-12-12 19:45

    If you want to use it in HTML Still you can use ~, see this

     href = @Url.Content("~/controllername/actionName")
    

    See the check box click event in my MVC Application

    @Html.CheckBoxFor(m=>Model.IsChecked,  
       new {@onclick=@Url.Content("~/controller/action("+ @Model.Id + ", 1)"), 
       @title="Select To Renew" })
    

提交回复
热议问题