html.actionlink

Route to different View(use @Html.ActionLink and ng-view in View) in Asp.Net MVC with AngularJS, ng-view only work one time, location url strange

非 Y 不嫁゛ 提交于 2019-11-30 16:18:58
问题 In my case, I need use @Html.ActionLink to Route to different View with AngularJS.In each view1/index.cshtml in asp.net has <div ng-view></div> that will load its html template. the following link image is my project structure: click My problem is: it only route success first time.I think it cause wrong location url. Views/Share/_Layout.cshtml: <ul> <li>@Html.ActionLink("Home", "Index", "Home")</li> <li>@Html.ActionLink("Device Management", "Index", "DeviceManagement")</li> </ul> Views/Home

ASP MVC3 insert html tag inside actionlink

故事扮演 提交于 2019-11-30 13:40:58
I'm new to the ASP MVC3 and I'm using Razor Engine. My broplem is that I've build my main navigation in form <nav> <ul> <li><a href=""><b>Link</b></a></li></ul></nav> So how I can do this with the actionlink? I just need to insert b tag inside a tag. Denis Agarev Use @Url.Action() to get href value instead of @Html.ActionLink Replace this: <a href=""><b>Link</b></a> With @Html.ActionLink("<b>Link</b>", "Action", "Controller") That may auto encode the <b></b> , so you can try: @Html.ActionLink(new MvcHtmlString("<b>Link</b>").ToHtmlString(), "Action", "Controller") Even more simply put, you can

ASP MVC3 insert html tag inside actionlink

我的梦境 提交于 2019-11-29 19:36:35
问题 I'm new to the ASP MVC3 and I'm using Razor Engine. My broplem is that I've build my main navigation in form <nav> <ul> <li><a href=""><b>Link</b></a></li></ul></nav> So how I can do this with the actionlink? I just need to insert b tag inside a tag. 回答1: Use @Url.Action() to get href value instead of @Html.ActionLink 回答2: Replace this: <a href=""><b>Link</b></a> With @Html.ActionLink("<b>Link</b>", "Action", "Controller") That may auto encode the <b></b> , so you can try: @Html.ActionLink

How to use CSS on an Html.ActionLink in C#

无人久伴 提交于 2019-11-29 17:19:30
问题 I tried this code <%: Html.ActionLink("Home", "Index", "Home", new { @class = "NavLink" })%> and it links to the css so that I can style the link, but it changes the link to have a different URL that is not to my controller like it is without the new { @class = "NavLink" } . Is there any way to let me style these links without ruining my URLs so they go to the correct pages? Thanks! 回答1: Make sure you are using the proper overload: <%: Html.ActionLink("Home", "Index", "Home", null, new {

Using “data-toggle” with Html.ActionLink

最后都变了- 提交于 2019-11-29 15:57:47
问题 I want to use "data-toggle" wiht actionLink. Like this; Html.ActionLink("Delete", "Users", "Admin", new { item.UserId , strRole = strRole }, new { id = "cmdDelete", href="#myAlert", data-toggle="modal" }) Unfortunately, doesn't accept. How can i use "data-toggle" like standart links? 回答1: You can't. But there is a simple work-around. What you do is, replace the - with a _. During runtime it will get converted to a dash (-). So; Html.ActionLink("Delete", "Users", "Admin", new { item.UserId ,

Create a T4MVC ActionLink with url fragment

放肆的年华 提交于 2019-11-29 13:22:10
Is there a way to create a strongly typed T4MVC ActionLink with a hash/pound/fragment in it? For example, here is the link I'd like to create: <a href="/Home/Index#food">Feed me</a> But there's no extension to the T4MVC object that can do this. <%= Html.ActionLink("Feed me", T4MVC.Home.Index()) %> So, what I end up having to do is create an action, and then embed it that way: <a href="<%= Url.Action(T4MVC.Home.Index()) %>"#food>Feed me</a> This isn't very desirable. Anyone have any ideas/suggestions? Thanks in advance This kind of approach is the only one i can think of that feels (to me)

MVC3 Html.ActionLink Post

若如初见. 提交于 2019-11-29 10:34:30
I have an MVC3 C#.NET web app and need to call a view using Html.ActionLink. I can't tell from the documentation if I can specify the POST or GET. Below is my HTML, is there a way to specify GET or POST? @Html.ActionLink("Create New", "Edit", "Subtask", new {Id = ViewBag.Id, Command="CreateHourEntry"}, null) Adam Tuliper - MSFT If you want a post use Ajax.ActionLink but be aware it's an Ajax post. You could easily use jquery to cause your existing link to cause a form post but this functionality is not included in Html.ActionLink. See ASP.NET MVC ActionLink and post method HTML hyperlinks send

System.Web.Mvc.HtmlHelper' does not contain a definition for 'ActionLink'

穿精又带淫゛_ 提交于 2019-11-29 01:07:51
I would like to use custom @Html.ActionLink I am trying to use the following code:- public static class LinkExtensions { public static MvcHtmlString MyActionLink( this HtmlHelper htmlHelper, string linkText, string action, string controller) { var currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString("action"); var currentController = mlHelper.ViewContext.RouteData.GetRequiredString("controller"); if (action == currentAction && controller == currentController) { var anchor = new TagBuilder("a"); anchor.Attributes["href"] = "#"; anchor.AddCssClass("currentPageCSS"); anchor

How to pass Area in Url.Action?

别等时光非礼了梦想. 提交于 2019-11-28 18:33:05
The problem in Html.ActionLink() is that you can't add additional html content inside the tag that it generates. For example, if you want to add an icon besides the text like: <a href="/Admin/Users"><i class="fa fa-users"></i> Go to Users</a> Using Html.ActionLink(), you can only generate: <a href="/Admin/Users">Go to Users</a> So, to resolve this, you can use Url.Action() to generate only the URL inside the tag like: // Here, Url.Action could not generate the URL "/admin/users". So this doesn't work. <a href="@Url.Action("", "Users", "Admin")"><i class="fa fa-usesr"></i> Go to Users</a> //

Create a T4MVC ActionLink with url fragment

六月ゝ 毕业季﹏ 提交于 2019-11-28 07:15:21
问题 Is there a way to create a strongly typed T4MVC ActionLink with a hash/pound/fragment in it? For example, here is the link I'd like to create: <a href="/Home/Index#food">Feed me</a> But there's no extension to the T4MVC object that can do this. <%= Html.ActionLink("Feed me", T4MVC.Home.Index()) %> So, what I end up having to do is create an action, and then embed it that way: <a href="<%= Url.Action(T4MVC.Home.Index()) %>"#food>Feed me</a> This isn't very desirable. Anyone have any ideas