Html.ActionLink Showing Query Url Instead Of Pretty Url?

Apr 12, 2010

The Html.ActionLink

<li> ${Html.ActionLink<HomeController>(c => c.Edit(ViewData.Model.Id, ViewData.Model.Title), "Edit")} </li>


When created as html shows the URL to be Edit/5006?title=One . How do I change this to a pretty URL like Edit/5006/One ?

My Edit Action method is,public ActionResult Edit(int id, string title)

View 3 Replies


Similar Messages:

MVC :: Html.ActionLink - Not Showing Correct URL

Jan 25, 2011

Over the past 3 days I've been trying to do everything in MVC. I want to learn this awesome technology.

I have just faced a problem with Html.ActionLink and I can't figure it out ! Here is what I have in my Home Index View:

[Code]....

View 8 Replies

MVC :: ASCX Html.ActionLink Not Showing

Aug 12, 2010

I assume this link is correct

Html.ActionLink("Edit", "Edit" , new {Controller = "Item", id = item.Product_GUID});

the books tell me things i have read etc.i should render html as <a href="/Edit/Item?id=foo>Edit</a>

I am sending them to "another controller" to edit the item...

But this is not rendering the hyperlink in my browser, UGH....

this code is in a ascx page so i can call it with partialaction.

All i can think is that its not working because its 5am and i have been up since 9am yesterday..

View 5 Replies

C# - How To Route "pretty" Dynamic URL (without Query String)

Dec 20, 2010

Well, i know the title isn't very specific, but i couldn't find a better succint description of what i'm looking for.i want to have a default.aspx so that when a user types:

http://www.mydomain.com/randomstring

i can use the randomstring to query a table on page load. More specific:

. I will be importing batches of users to my database through a csv file.

. in that process, a random string will be generated

. i will send that url to each user by email

. when the user clicks through that link, i want my aspx(c#) to interpret that string, query a table that gives me a second url, this one with querystring, and Redirects the user to that second address

View 1 Replies

Html.ActionLink() Gives An Empty Link When Use It Inside Html.RenderAction()?

Feb 18, 2010

I have a Microsoft MVC project with an action "Foo" whose view ("Foo.aspx") contains the lines:

<%= Html.ActionLink("mylinktext1", "bar") %>
<%= Html.ActionLink<MyController>(x => x.Bar(), "mylinktext2") %>

When I hit this from a web browser or load it from an AJAX call, it properly returns:

<a href="/bar">mylinktext1</a>
<a href="/Bar">mylinktext2</a>

But when I call the action from another view like this:

<% Html.RenderAction<MyController>(x => x.Foo()); %>

Then the links are rendered without targets.

<a href="">mylinktext1</a>
<a href="">mylinktext2</a>

Why would this be happening, and how do I work around it?

View 1 Replies

Javascript - Html.ActionLink In Html.TreeView?

Dec 18, 2010

Im using the HTML.TreeView to render my code structure like this :
<%= Html.TreeView("CategoryTree",
Model.CategoryList,
l => l.ChildList,
l => l.Name + " / <a id="treeLnk" + l.Id + "" href="JavaScript: OpenAddDialog('" + l.Name + "', " + l.Id + ") " title="Lägg till" >Lägg till</a>" +
" / <a id="treeLnk" + l.Id + "" href="JavaScript: OpenChangeNameDialog('" + l.Name + "', " + l.Id + ") " title="Ändra namn" >Ändra namn</a>" +
" / <a id="treeLnk" + l.Id + "" href="JavaScript: OpenDeleteDialog('" + l.Name + "', " + l.Id + ") " title="Tabort" >Tabort</a>") %>

This work fine, but now I need to include a action that redirects to another controlleraction.

I have tried to ad a Html.ActionLink but this does not work?

View 1 Replies

C# - How To Html.ActionLink And HTML As Parameter

Jul 31, 2010

Html.ActionLink("<span class="title">Retry</span><span class="arrow"></span>", "Login", "User")

If I execute above code in ASP.Net MVC 2, I get the following output on my screen:

How do I disable the escaping of the code, so my span is within the ActionLink, and not displayed as output?

I know this is expected behavior, to keep it safe, but I want it to interpret the HTML code I pass as a parameter.

View 4 Replies

Using Html.ActionLink But Not Html Encoding?

Oct 19, 2010

I wish to return the following output

<a href="#"><img src="/images/icons/tick.png" alt="" />More info</a>

If i do the following the content is html encoded.
<%= Html.ActionLink("<img src='/images/icons/tick.png' />More info", "OrderRegion", "Campaign", new {id = Model.Campaign.Id}, null) %>

How can i disable the html encoding?

View 2 Replies

How To Use Html.ActionLink()

Dec 18, 2010

I'm pretty new to ASP.Net / MVC 2. Can anyone explain how to use the Html.ActionLink thing? I understand that the first parameter is the displayed text, but for the second one, what is the action name?

View 1 Replies

Use An Asp:Button Like An Html.ActionLink?

Jul 4, 2010

I have an ActionLink: <%: Html.ActionLink("MyAction", "MyAction") %> I would like to use a button instead. Something like this: <asp:Button ID="Button1" runat="server" Text="MyAction" /> What do I need to do to make clicking the button perform the same action as clicking the ActionLink?

View 1 Replies

C# - Html ActionLink Isn't Displaying?

Jan 5, 2011

I'm showing a small table with a list of usernames, and I want an ActionLink next to each username to Edit the user on another page.

[code]...

The usernames display correctly, just the link doesn't show up. I'm not sure why it wouldn't throw an error instead.What am I missing here?

View 2 Replies

MVC :: Url.RouteUrl Vs Html.ActionLink Vs Url.Content

Jun 28, 2010

I was reading the ASP.NET MVC Best Practices article by Rashid, and got stuck in his description of creating UrlHelper extensions. Doing this is easy enough, and I've adopted the practice into all of my projects. I noticed, however, that Rashid used Url.Content to generate the url for the home page, and Url.RouteUrl for all the other urls. Why is this? What is the difference between the two?

The link to the blog post is here:
http://weblogs.asp.net/rashid/archive/2009/04/01/asp-net-mvc-best-practices-part-1.aspx

I've used Html.ActionLink in my Views, but I'm wondering what difference it would be if I used Url.RouteUrl instead. Does anyone have a good grasp of what makes these helpers different, and where they are best used?

View 1 Replies

MVC :: Two Html.ActionLink In A Column Using Webgrid?

Feb 15, 2011

I m facing a problem in WegGrid MVC 3 razor, my code:

[Code]....

How to merge the Edit & Delete links into the same column (Actions)??

i tried to create two (item) in same column, but i get error message.

View 7 Replies

Stuff Viewmodel Into Html.actionlink?

May 7, 2010

Is there a way to stuff my ViewModel into an Ajax.ActionLink? edit I'd like to take my 5 search fields on my page which are bind to a view model and send it along my .ActionLink as my object value parameter.

View 2 Replies

Insert Image In Html.actionlink - Mvc?

Sep 8, 2010

how to insert image in html.actionlink - asp.net mvc? i did it so, but it doesnt works.

<a href="<%= Html.ActionLink("search", "Search", new { searchText = "txtSearch" }, null); %>">
<img alt="searchPage" style="vertical-align: middle;" height="17px"
src="../../Stylesheets/search.PNG" title="search" />

View 2 Replies

MVC 3 RC Html.Actionlink Not Generating Link

Dec 6, 2010

I have a route (the first one listed) which looks like this:

routes.MapRoute(
"TopicRoute", // Route name
"forums/{forumSlug}/{topicSlug}", // URL with parameters
new { controller = "Forums", action = "Topic"} // Parameter defaults
);

I can browse to: /forums/my-forum/my-topic and the page loads fine. Yet I have a Html.ActionLink that looks like: @Html.ActionLink(item.Title, "Topic", new { forumSlug ="my-forum", topicSlug = "my-topic" }) And it won't generate the correct link syntax for me? It generates: <a href="">My Topic</a>

View 1 Replies

Using CSS In ActionLink Inside HTML.Partial

Mar 22, 2011

I'm having problems getting my CSS class to style an actionlink inside a html.partial. In building my test site, I've used the template beginning from ASP.NET and the standard login portion. My Index page works fine as the _Layout.cshtml does reference my css page. In _LogOnPartial, I have the following listed (there is more but this is what's important I believe):

else {
<text>
<ul style="display:inline;">;
<li style="list-style:none; display:inline;">
@Html.ActionLink("Sign In", "LogOn", "Account", null, new { @class = "signin" })
</li>

My CSS for "signin" is:

.signin {
text-decoration: none;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
color: White;
}

When I look at the source for the page after debugging, it shows:

<a class="signin" href="/Account/LogOn">Sign In</a>

That looks right but it's not showing it correctly. The font isn't Helvetica and it is underlined and not white. I don't reference the css sheet in the LogOnPartial but I didn't think I'd have too.

View 2 Replies

MVC :: Using Dynamic Text With HTML.Actionlink

Sep 28, 2010

as part of my web app i have a series of buttons created using HtmlActionlink e.g

<%=Html.ActionLink("Swap User",
"Index","Home")%></td>

However my buttons need to be translated into difrent languages depending on the country the user is in Im translating the button lable text fine in my controller and passing it into the view , but now im alittle stumped over syntax Id like to replace "Swap User" above with

<%=Html.Encode(ViewData["swapUser"]) %>

but im failing miserably finding the right syntax

View 2 Replies

MVC :: Html.ActionLink Parameter Order

May 25, 2010

I've never been able to understand why it is that some things are made in a particular way, and Html.ActionLink is one of these. In Global.asax, if I want to create a route, it has the format:

[Code]....

The order of the necessary parameters here is "name/controller/action/extra params". When using Html.ActionLink, the parameter order is "name/action/controller/extra params", which is much the same but with two of them switched around. To make things more confusing, the rendered html from the Html.ActionLink has the original order "controller/action/extra params" with the name inside of the anchor tag. Why do this? It's easy enough to memorize that the order is switched for absolutely no reason I can discerne, but why do it in the first place?

View 8 Replies

MVC :: How To Disable The Html.ActionLink() After Clicking On It

Jul 23, 2010

I need to disable the Html.ActionLink() after clicking on it. Means i want to populate all the records from database after clicking on link but after populating hat link should be disabled.

View 5 Replies

C# - Add Dynamic Html.ActionLink In Javascript?

Jan 29, 2011

Is there a way to add a Html.ActionLink through javascript? For instance, I have this Edit function in my controller:

public ViewResult Edit(int companyID)
{
....
}

And I'd like to do something like this in javascript:

var id = $("#hdnID").val();
$("#editLink").html(<%: Html.ActionLink("Edit", "Edit", new { id }) %>);

A bit of a crude example, but it's basically what I'd like to do. Is it at all possible?

View 3 Replies

MVC :: Display Html.Actionlink Through Controller?

Oct 16, 2010

I am trying to display Html.Actionlink through controller(MVC). Here is the example what am trying to do...

public string test(){
string testString = "<%: html.ActionLink('click', 'test', new AjaxOptions() { UpdateTargetId = 'test' }) %>";
return testString;
}

i want to display testString in view. but am not getting the actionlink in view..i can display anchors which is given below:-

public string test(){
string testString = "<a href ="test"> click here</a>";
return testString;
}

View 3 Replies

MVC :: Sending Parameters With Html.ActionLink?

Feb 11, 2011

How can we send these parameters in Html.ActionLink statement?(one by one not all of them)

1- selected value of a DropDownList.

2- Form collection.

3- our Model.

View 5 Replies

MVC :: Embed An Image In Html.ActionLink?

Feb 28, 2011

I want to embed an image in Html.ActionLink instead of using a text.

Here is what I am using:

<li> <%: Html.ActionLink("4WD", "Browse4WD", "Vehicles", new { categoryName = "4WD" }, null)%></li>

The link display the text "4WD" (1st parameter).

I want to display the image instead "4WD".

I have an image stored under Content folder, I tried this:

<li>
<a href= "<%= Url.Action("Browse4WD", "Vehicles")%>" >
<img src="<%= ResolveUrl("~/Content/4WDImageGroup.jpg")%>" />
</a>
</li>

But the web page did not display image but only the 'cross'. Looks like cannot find the path of the image.

View 4 Replies

MVC :: Passing Sensitive Information Through HTML ActionLink?

Jan 29, 2011

I did some google searching on this, but I could not find anything useful.

Basically what I am trying to do is pass some sensetive information to an ActionResult through the click of a HTML ActionLink.

The information I need passing through is, the ProductID and the User IP Address.

So just to clarify:

1) User clicks { I like Product } link (HTML ActionLink)

2) That sends the Product ID and the IP Address of the user to the ActionResult in the Controller.

View 11 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved