点击事件上的mvc锚标记 [英] mvc anchor tag on click event

查看:91
本文介绍了点击事件上的mvc锚标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带索引和coursedetails动作的注册控制器。

在我的视图中我有一个锚标记。当我点击锚标签时,我想调用coursedetails动作。但索引动作正在调用

这是我在视野中的事件

onclick =location.href ='@ Url.Action(DDMVC.Registration.coursedetails(Nevada, @ item.Name))'





请提供答案

I have registration controller with index and coursedetails actions.
in my view i have a anchor tag. when am click on the anchor tag i want to call coursedetails action. but index action is calling
this is my event in view
onclick="location.href='@Url.Action(DDMVC.Registration.coursedetails("Nevada", @item.Name))'"


please provide the answer

推荐答案

请一想。

step-1>在索引页面内创建空潜水

步骤2>为锚标签创建一个onclick事件

step-3>在onclick事件中调用你必须在脚本中创建的函数。

step-4>然后你可以在
Do one think.
step-1>create a empty dive inside index page
Step-2>Create a onclick event for anchor tag
step-3>in the onclick event call a function that you have to create in your script.
step-4>then you can call the action with the help of

<的帮助下调用动作通过定义url,参数以及获取或发布类型操作来获取


.ajax

step-5>获取部分视图结果并在html中呈现并分配给相同的div功能。



此解决方案用于在索引页面中显示部分视图(课程详情)。



但是如果你单独想要加载课程详情页面,那么你可以使用acti在链接而不是锚标签。



如果您发现我的答案有用,那么您可以随时点击绿色勾选标记接受解决方案
.ajax by defining the url, parameters and get or post type actions
step-5>Get the partial view result and render it in html and assign to the div in the same function.

This solution is for showing a partial view(Course details) in your index page.

but if you separately want to load the course details page then you can use action link instead of anchor tag.

If you find my answer useful then you can always click on green tick mark to accept the solution


希望它会对你有帮助,



< a href =/ Home / Test> sampleclick< / a>


这个网址中的
Home是一个控制器,Test是我打电话的方法。
Hope it will help you,

<a href="/Home/Test" >sampleclick</a>

in this url Home is a controller and Test is a method that i am calling.


这篇关于点击事件上的mvc锚标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆