单击事件URL,使用javascript / Jquery在asp.net MVC中打开另一个页面

Click event URL to open another page in asp.net MVC using javascript/Jquery
2021-09-15
  •  译文(汉语)
  •  原文(英语)

是否可以在Calendar上单击事件(我使用的是fullcalendar插件)并重定向或使用javascript / Jquery在asp.net MVC中打开与此事件ID相关的详细信息视图页面,因此代码将为所有活动都使用相同的URL?Fullcalendar已集成到asp.net mvc中.

我写了这段代码,但是没有用:

eventClick: function(calEvent, jsEvent, view) {
    window.location = "<%= Url.Action("Details", "ReservationRequests", new { id = 
 Model.ID})

谢谢您的帮助!

速聊1:
是的,它有可能.但首先,您应该尝试一些事情.
速聊2:
我尝试了eventClick函数,但没有起作用,给出了异常错误.我编辑了问题以发布代码.请帮我.谢谢!
解决过程1

您的重定向代码缺少结尾 ";

尝试

$(document).ready(function() {
    $('#calendar').fullCalendar({
        eventClick: function() {
            window.location = "<%= Url.Action("Details", "ReservationRequests", new { id = Model.ID})%>";
        }
    });
});

其中calendar是div的ID.

速聊1:
如果这不能解决问题,您能否发布您遇到的异常?
速聊2:
这是异常详细信息: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Is it possible to click on the event on the Calendar (I'm using a fullcalendar plugin) and get redirected or open a Details view page in asp.net MVC related to this eventID using javascript/Jquery, so that the code will give the same URL to all events? Fullcalendar is integrated into asp.net mvc.

I wrote this code, but it didn't work:

eventClick: function(calEvent, jsEvent, view) {
    window.location = "<%= Url.Action("Details", "ReservationRequests", new { id = 
 Model.ID})

Thank you for your help!

Talk1:
yes its possible. but first you should try something.
Talk2:
I tried the eventClick function, but it didn't work, giving an exception error. I edited my question to post the code. Please help me. Thank you!
Solutions1

Your code for redirecting missing the closing ";

Try

$(document).ready(function() {
    $('#calendar').fullCalendar({
        eventClick: function() {
            window.location = "<%= Url.Action("Details", "ReservationRequests", new { id = Model.ID})%>";
        }
    });
});

Where calendar is the id of the div.

Talk1:
If this doesn't fix it, could you post the exception you are getting?
Talk2:
This is the exception details: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
转载于:https://stackoverflow.com/questions/15559949/click-event-url-to-open-another-page-in-asp-net-mvc-using-javascript-jquery

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入