Displaying multiple #Html.ActionLink in same line - html

How can I display 2 Html Action Links in a same line, that are using different action from a different controller? My code is:
<th>#Html.ActionLink((item.Name + " & "), "Index", "Wedding") #Html.ActionLink("Invite Partner", "InvitePartner", "Account")</th>
With this both actions are displayed in a different paragraph. How can I display them in a same paragraph?
EDIT:
It is all about the style, I've added bootstrap classes, and it is showing as buttons in same paragraph:
<th>#Html.ActionLink((item.Name + " & "), "Index", "Wedding", new { #class = "btn btn-default"}) #Html.ActionLink("Invite Partner", "InvitePartner", "Account", new { #class = "btn btn-danger"})</th>

Related

html entity in ActionLink

How can I include html entities in ActionLink. e.g. The case of » below.
<p>#Html.ActionLink("Link Text »", "Index", new { }, new { #class = "btn btn-warning", #role = "button" })</p>
Use Url.Action instead
<p><span class="btn btn-warning">Link Text »</span></p>

How to incorporate href to section with Html.ActionLink in MVC?

I am new to MVC and have encountered a problem. I have an HTML page that scrolls down to a section when that section's name is clicked from the navigation bar but now I have to change this HTML line of code to MVC:
<li><a class="page-scroll" href="#services">Services</a></li>
I have tried to use Html.ActionLink but have not had any success yet!
What I have so far:
#Html.ActionLink("Services", "Index", "Home", new { area = "#services" }, new { #class = "page-scroll" })
Create your own helper or use raw html
<li>Link Text</li>
OR
<%= Html.ActionLink("Link Text", "Action", "Controller", null, null, "services", new { parameter = "example"}, null) %>
On your Index page:
<div id="services">
<p>Here is the content you want to make show when you click the link</p>
</div>
When you click on 'Link Text' it will direct you to the services section of your Index page.
Try
#Html.ActionLink("Services", "Index", "Home#services", new { #class = "page-scroll" })

How can I add a caret to text passed to #Html.ActionLink in MVC5

I want to display
Username v
as the text displayed for the link.
I wanted to use <class = "caret"> but I can't pass it successfully and the HTML code is being printed next to Username.
In most cases the Html.ActionLink will do the trick, if you want more control over the href tag you can use #Url.Action.
Examples:
#Html.ActionLink(Model.Username, "Username", "Account", new { #class = "caret" })
HTML Result: <a class="caret" href="/Account/Username">SomeUsername</a>
<a class="caret" href="#Url.Action("Username", "Account")">#Model.Username</a>
HTML Result: <a class="caret" href="/Account/Username">SomeUsername</a>

Single select with chosen with razor

So i have implemented Chosen with my project and worked great with multi select but i want to add that for simple dropdown. I have total of 80 entry in dropdown so need the search function of chosen..this is my code.
<div class="editor-label">
<span style="color: red;">*</span> <strong>Select Therapist:</strong>
</div>
<div class="editor-field">
#Html.DropDownList("TherapistList", Model.TherapistList
, new
{
#class = "chzn-select",
data_placeholder = "Choose Therapist",
}
)
</div>
and
<script >
$(".chzn-select").chosen({
allow_single_deselect: false,
search_contains: false,
no_results_text: "Oops, nothing found!"
});
</script>
i have addded the CSS and .JS reference on top. Its working fine with multiselet when i add #Html.ListBox("TherapistList", Model.TherapistList
but i want single select with search option as they display on website.
thanks in advance.
If you don't call #Html.Listbox but #Html.DropDown you will get a single select chosen.
#Html.DropDownList("TherapistList", Model.TherapistList, new {
#class = "chzn-select",
data_placeholder = "Choose Therapist",
}
)

<text> tag in _LoginPartial.cshtml

The _LoginPartial.cshtml file created by the MVC 4 template contains a <text> tag, like this:
<text>
Hello, #Html.ActionLink(User.Identity.Name, "Manage", "Account", routeValues: null, htmlAttributes: new { #class = "username", title = "Manage" })!
#using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" })) {
#Html.AntiForgeryToken()
Log off
}
</text>
As far as I can tell, <text> is not a recognized tag, so why did the folks who created this code use that tag?
As the commenters to the OP said, <text> is special Razor syntax to denote text. As ScottGu's Blog explains, this syntax can be used in lieu of the #: syntax.