actionlink

Ajax.ActionLink will not work if validation is false?

做~自己de王妃 提交于 2019-12-11 10:31:48
问题 @Ajax.ActionLink("like", "Like", "Article", new { postId = Model.post.PostId, userName = User.Identity.Name }, new AjaxOptions { OnBegin = "OnBegin" }, new { @class = "like_link" }) function OnBegin() { if( true ) // value from client side. not returning value from server. { // I dont want to work the link. I want only alert message. } else { // Go to controller with parameters. } } I want something like above. OnBegin is not neccesary to do it. May be another solutions. Thanks. 回答1: OnBegin

MVC - why use ActionLink instead of hard coding the link?

浪子不回头ぞ 提交于 2019-12-11 07:51:36
问题 Microsoft MVC, Razor, Visual Studio 2013 I can create a link using either of these 2 methods. Is there any benefits in using the Html.ActionLink method, as I cannot see any ? <a href="/Review/MyReviews">My Reviews</a> @Html.ActionLink(linkText:="My Reviews", controllerName:="Review", actionName:="MyReviews") thanks, John 回答1: Yes. It is useful to use Url.Action() for url generation and Html.ActionLink() to generate anchor tags as it will make sure to generate correct relative Url from the

ActionLink contains slash ('/') and breaks link

倖福魔咒の 提交于 2019-12-11 07:17:38
问题 I have an Action Link that's as follows: <td>@Html.ActionLink(item.InterfaceName, "Name", "Interface", new { name = item.InterfaceName}, null)</td> item.InterfaceName is gathered from a database, and is FastEthernet0/0 . This results in my HTML link being created to lead to "localhost:1842/Interface/Name/FastEthernet0/0" . Is there a way to make "FastEthernet0/0" URL friendly so that my routing doesn't get confused? 回答1: You could work around this, by replacing the slash. ActionLink(item

MVC2: How can I read control values for an action link?

夙愿已清 提交于 2019-12-11 06:25:32
问题 I'm passing in some model information to an ActionLink, but I'd also like to provide the action with the values of some inputs on the page. For example, if I had something like this: <input Name="MyInput" /> <%: Html.ActionLink("MyAction", "MyController", Model.Value); I'd like the action to be aware of both Model.Value (which is passed in via parameter), and the value of MyInput. Normally I would use a FormCollection, but I can't in this instance since I'm not doing a submit. So how can I

ASP.NET MVC: Ajax.Actionlink Does not work with parameters

Deadly 提交于 2019-12-11 06:07:20
问题 <%= Ajax.ActionLink("DrillDown", "EventOverzichtAjax", new { GroepID = Model.GroepID.ToString(), groepType = Model.GroepType.ToString(), manager = Model.isManager }, new AjaxOptions { UpdateTargetId = Model.GroepID.ToString(), OnBegin = string.Format("beginOverzichtFetch('{0}')", Model.GroepID), OnComplete = string.Format("completeOverzichtFetch('{0}')", Model.GroepID)}) %> I'm having some issues with the onBegin and onComplate properties. They work perfectly as i want. But they do not when i

Dynamic Ajax ActionLink RouteValues

别等时光非礼了梦想. 提交于 2019-12-10 15:37:48
问题 I have an ActionLink link this @Ajax.ActionLink("Delete it!", "Delete", new {id = getTheID}, new AjaxOptions { Confirm = "Really?", HttpMethod = "Delete", UpdateTargetId = "ddlRoles" }) and I want to insert the route value "id" on click. The value I want to read from is a drop-down list, so I got something like this in javascript to get the value: $('#ddlRoles :selected').val() I already read this post set ActionLink routeValues dynamically but I'm not sure how the syntax should look like,

asp.net mvc: How to image map?

青春壹個敷衍的年華 提交于 2019-12-10 10:50:01
问题 How in ASP.NET MVC would I construct an image map? For ref: <map id='headerMap'> <area shape='rect' href="Default.aspx" coords='300,18,673,109' /> </map> One answer of an answer of an unrelated question by markus is something similar: <a href="<%= Url.RouteUrl("MyRoute", new { param1 = "bla", param2 = 5 }) %>"> put in <span>whatever</span> you want, also <img src="a.gif" alt="images" />. </a> Sorry if this is redundant. My research indicated that this may be a version 2 mvc answer. Looking

$(document).ready in ascx page after ajax callback

时间秒杀一切 提交于 2019-12-10 05:44:59
问题 I'm having a little problem with this setup here I have a list of .ascx files and they all do different tasks in terms of calculations to the controller itself. So on my .aspx page I click on an Ajax.ActionLink() and this will render that specific .ascx file based on the item I clicked. Within that .ascx are 1-3 events that will fire 2 of them are onclick events and 1 is onload . The onclick event(s) are easier to work with in terms of I can hardcode it directly in the controls event like so

ASP.NET MVC: generating action link with custom html in it

两盒软妹~` 提交于 2019-12-10 03:15:09
问题 How can I generate action link with custom html inside. Like following: <a href="http://blah-blah/....."> <span class="icon"/> New customer </a> 回答1: You can use the UrlHelper class : <a href="<% =Url.Action("Create","Customers") %>"> <span class="icon"/> New customer </a> The MSDN link is here : http://msdn.microsoft.com/en-us/library/system.web.mvc.urlhelper.aspx 来源: https://stackoverflow.com/questions/3879547/asp-net-mvc-generating-action-link-with-custom-html-in-it

Using Html.ActionLink and Url.Action(…) from inside Controller

怎甘沉沦 提交于 2019-12-10 02:02:21
问题 I want to write an HtmlHelper to render an ActionLink with pre-set values, eg. <%=Html.PageLink("Page 1", "page-slug");%> where PageLink is a function that calls ActionLink with a known Action and Controller, eg. "Index" and "Page". Since HtmlHelper and UrlHelper do not exist inside a Controller or class, how do I get the relative URL to an action from inside a class? Update: Given the additional three years of accrued experience I have now, here's my advice: just use Html.ActionLink("My Link