WORKS
<a href="#Url.Action("edit", "markets", new { id = 1 })"
data-rel="dialog" data-transition="pop" data-icon="gear" class="ui-btn-right">Edit</a>
DOES NOT WORK - WHY?
#Html.ActionLink("Edit", "edit", "markets", new { id = 1 }, new {#class="ui-btn-right", data-icon="gear"})
It seems you can't pass something like data-icon="gear" into htmlAttributes?
Suggestions?
The problem is that your anonymous object property data-icon has an invalid name. C# properties cannot have dashes in their names. There are two ways you can get around that:
Use an underscore instead of dash (MVC will automatically replace the underscore with a dash in the emitted HTML):
#Html.ActionLink("Edit", "edit", "markets",
new { id = 1 },
new {#class="ui-btn-right", data_icon="gear"})
Use the overload that takes in a dictionary:
#Html.ActionLink("Edit", "edit", "markets",
new { id = 1 },
new Dictionary<string, object> { { "class", "ui-btn-right" }, { "data-icon", "gear" } });
Replace the desired hyphen with an underscore; it will automatically be rendered as a hyphen:
#Html.ActionLink("Edit", "edit", "markets",
new { id = 1 },
new {#class="ui-btn-right", data_icon="gear"})
becomes:
<form action="markets/Edit/1" class="ui-btn-right" data-icon="gear" .../>
#Html.ActionLink("Login", "Index", "hahgshg62jjshags",new { },new { rel = "nofollow", style = "color:white" })
#Html.ActionLink("display name", "action", "Contorller"
new { id = 1 },Html Attribute=new {Attribute1="value"})
Related
I need to open the link in new page when click the link but where to add the code
new {target = "_blank"}
in this link ,
<td>#Html.ActionLink("Result", "MasterDetails", new { id = item.LabOrders.ORDER_ID }, new { #class = "btn btn-primary" })</td>
It's part of the htmlArguments, after the route value. You don't necessarily put the whole thing in; you merge with other html arguments, such as #class:
<td>
#Html.ActionLink("Result", "MasterDetails",
new { id = item.LabOrders.ORDER_ID},
new { #class = "btn btn-primary", target="_blank" })
</td>
Action link #class="info" not working for css
#Html.ActionLink("Click Here", "Details", "Product", new { id = item.ProductId, #class="info" },null)
Html page source
Click Here
Update:
on the other hand
if i set #Html.ActionLink("link here", "Details", "Product", new { id = item.ProductId}) then generate this link localhost:18715/Home/Details?Length=7 why? and it is not working
if i set #Html.ActionLink("link here", "Details", "Product", new { id = item.ProductId},null)
it is working perfectly generate this link http://localhost:18715/Product/Details/17
what i am missing for each link
You have to write hmtl attributes like this:
#Html.ActionLink("Click Here", "Details", "Product", new { id = item.ProductId }, new { #class = "info"})
#Html.ActionLink("Back", "Index", " ", new { #class = "col-sm-3 btn btn-outline-secondary btnfs btn-sm" })
Here more than one CSS calls is attached to the for ActionLink. This is For
Asp.net MVC
I want to use ActionLink instead of plain html to popup my modal window but its working fine with plain html tag but not with MVC actionlink please have a look below.
from: (working)
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
to: (error)
#Html.ActionLink("Edit", "Edit", null, new { id = #item.Id }, new { #data-toggle="modal", #data-target="#myModal" })
Invalid anonymous type member declarator. Anonymous type members must
be declared with a member assignment, simple name or member access.
You need to use the underscore character instead or the hyphen character in the attribute name (the html helper will output the html correctly). Note also the # character is not required (its only necessary when using a reserved word, e.g. class or readonly)
#Html.ActionLink("Edit", "Edit", null, new { id = #item.Id }, new { data_toggle="modal", data_target="#myModal" })
#Html.ActionLink("TextLink", "ActionName", new { id = item.Id }, new { #class="btn btn-primary", data_toggle="modal", data_target="#exampleModal" })
I have the following code which looks into the "ProductCatalog" and returns items if found.
I need to edit the code in order for me to be able to enter multiple values or even special characters like >, <, and, or.
Is this possible?
<div class="search">
#*#using (Html.BeginForm("Search", "ProductCatalog", FormMethod.Get, new { name = "quickSearchform" }))*#
#using (Html.BeginForm("Search", "ProductCatalog", FormMethod.Get, new { name = "searchform", id = "searchform", onsubmit = "return validateSearch();" }))
{
#Html.TextBox("criteria", "Search", new
{
#class = "searchbox",
onfocus = "if (this.value==this.defaultValue) {this.value = ''}",
onblur = "if (this.value=='') {this.value = this.defaultValue}"
})
<a class="btn btnStyleC btn-search quickSearch" href="javascript:searchSumbitOnClick();">Search</a> #*<a class="btn btnStyleC btn-search" href="javascript:searchSumbitOnClick();">Search</a>*# } </div>
I am working on and Microsoft MVC3 project and cannot pass a parameter which has been edited to the controller. It will only pass back the original set parameter
For example:
#Ajax.ActionLink("share file", InviteController.Actions.Result, InviteController.Name, new { message = Model.Message }, new AjaxOptions
{
HttpMethod = "GET",
UpdateTargetId = "popup",
OnSuccess = "$('#popup').dialog('open')"
}, new { id = "popup-button" })
<label>Personal Message <span class="optional-message">(optional)</span></label>
#Html.TextAreaFor(x => x.Message)
</div>
This will pass the to the following controller but the 'message' parameter has the original message and not the updated message:
public ActionResult Result(FormCollection coll, string message)
{
I'd love if someone could give me some advice.
Many Thanks
Use a form instead:
#using (Ajax.BeginForm(
InviteController.Actions.Result,
InviteController.Name,
null,
new AjaxOptions
{
HttpMethod = "GET",
UpdateTargetId = "popup",
OnSuccess = "$('#popup').dialog('open')"
},
new { id = "popup-button" }))
{
<label for="Message">
Personal Message
<span class="optional-message">(optional)</span>
</label>
#Html.TextAreaFor(x => x.Message)
<button type="sybmit">share file</button>
}
And don't forget that HTML forms cannot be nested. So if you have an outer form this won't work.