Transform MVC Html.ActionLink to plain HTML with span - html

I am writing ASPNET MVC and I would like to use Html.ActionLink
I want however that the final HTML will look like this
from:
<li>#Html.ActionLink("Home", "Index", "Home")</li>
to:
<li>
<a href="layout-variants.html">
<i class="linecons-desktop"></i>
<span class="title">Home</span>
</a>
</li>
How can I transform

You should make use of Url.Action()
<li>
<a href="#Url.Action("Index","Home")">
<i class="linecons-desktop"></i>
<span class="title">Home</span>
</a>
</li>

Url.Action("Index","Home") is the way around it.
See the demo

public static string ActionLink(this HtmlHelper html, string url)
{
return "<i class=\"linecons-desktop\"></i><span class=\"title\">Home</span>"
}
Call from view: #Html.ActionLink("layout-variants.html"), you can change parameter for your project.

Related

How to redirect to about.jsp?

So I have this code snippet in spring mvc
<a class="nav-item is-hidden-mobile is-active roboto strong letter-space-1" href="">HOME</a>
<a class="nav-item is-hidden-mobile roboto strong letter-space-1" href="about.jsp"> ABOUT </a>
<a class="nav-item is-hidden-mobile roboto strong letter-space-1" href=""> CONTACT </a>
But when I click on the ABOUTon my landing page, it won't redirect, instead it displays error code 404. Are there other things to fix before I can redirect there, besides in the html file?
Try to create an endpoint in Controller that will return your about.jsp on some URL like that:
#Controller
public class HelloController {
#RequestMapping("/hello-about")
public String getHelloAbout(ModelMap model) {
return "/WEB-INF/jsp/about.jsp";
}
}
And change your link to point not to the about.jsp file but to the endpoint "/hello-about".
<a class="nav-item is-hidden-mobile roboto strong letter-space-1" href="/hello-about"> ABOUT </a>

How to make a link in #Html.LabelFor

I am working on the asp.net mvc project. I am generating a name with this code -
#Html.LabelFor(x => x.ReturnAirTemperature, new { style = "position: absolute;top: 310px;left: 18px;z-index: 10000;font-weight:bold" })
I have this model for it -
[Display(Name = "T(return)")]
public decimal ReturnAirTemperature { get; set; }
How can I create a link on "T(return)" text ?
You can also do something like this
<a class="" href="#Url.Action("ActionName","ControllerName", new { id=item.MyID })">
<i class="glyphicon glyphicon-pencil"></i>
<span class="sr-only">#Html.LabelFor()</span>
</a>
I suggest you to use like this:
<label for="#nameof(Model.ReturnAirTemperature )">u must agree our terms and conditions</label>

How to find Xpath for read the list of elements use list<Webelement>

webdriver finding xpath its too dificult for me. i used fire path most of fire path given xpath not working and its too lengthy. some one give me idea about xpath will work all conditions and i know relative xpath
some times this posibilities also not working like {//ul[#class='review-nav']}. some one help me for find xpath that xpath will work all conditions
<ul class="review-nav">
<li id="pend" class="pend tabclass">
<a onclick="OnTabSelect(1,'pend',0)" href="#">Pending (197)</a>
<span class="glyphicon glyphicon-filter filterclass" style="color:#185daa;top:4px;display:none"/>
</li>
<li id="flag" class="flag tabclass active">
<a onclick="OnTabSelect(4,'flag',1)" href="#">Flagged (96)</a>
<span class="glyphicon glyphicon-filter filterclass" style="color:#185daa;top:4px;display:none"/>
</li>
<li id="esca" class="esca tabclass">
<a onclick="OnTabSelect(5,'esca',2)" href="#">Escalated (88)</a>
<span class="glyphicon glyphicon-filter filterclass" style="color:#185daa;top:4px;display:none"/>
</li>
<li id="closed" class="closed tabclass">
<a onclick="OnTabSelect(3,'closed',3)" href="#">Closed (99)</a>
<span class="glyphicon glyphicon-filter filterclass" style="color:#185daa;top:4px;display:none"/>
</li>
<li id="all" class="all tabclass">
<a onclick="OnTabSelect(0,'all',3)" href="#">All (1,355)</a>
<span class="glyphicon glyphicon-filter filterclass" style="color:#185daa;top:4px;display:none"/>
</li>
</ul>
I try this Xpath to read above list its not working
xpath = //ul[#class='review-nav']
Sorry for that, I am little bit not clear for what you need xpath..
If you are trying to get all link ('a') to collect into List
//ul[#class='review-nav']/li/a
If you are trying to get all 'span' element to collect into List
//ul[#class='review-nav']/li/span
If you want to get specific element in specific li, you can try with id of 'li', for example if you like to find xpath of 'a' in first li
//li[#id='pend']/a
Thank You
Try with CSS:
.tabclass
You should get the 'li' elements with this.

Angular JS Display String Array From Json

<li ng-repeat="address in search.result.addresses">
<a href ng-click="selectAddress(address)">
{{address.addressLines}}
</a>
</li>
The problem is with my {{address.addressLines}}
This is currently a string array so my value on screen is printed out like
["address1","address2","address3","address4"]
But I just want it printed like
address1,address2,address3,address4
There are fundamentally 2 ways:
1) By using native angular directives:
<span ng-init="foo=[1,2,3,4]" ng-app="app">
<span ng-repeat="f in foo">{{f}}<span ng-if="!$last">,</span></span>
</span>
2) By writing a simple filter (best way):
angular.module('app', []).filter('arrayToList', function(){
return function(arr) {
return arr.join(',');
}
});
<p>{{foo|arrayToList}}</p>
This is the working example on jsfiddle: http://jsfiddle.net/g0dmazzk/
You can do this using join also :
<li ng-repeat="address in search.result.addresses">
<a href ng-click="selectAddress(address)">
{{address.addressLines.join()}}
</a>
</li>
I thing somthing like this would work...
<li ng-repeat="address in search.result.addresses">
<a href ng-click="selectAddress(address)">
<span ng-repeat="a in address.addressLines"> {{a}},</span>
</a>
</li>
To avoid dealing with the comma in the last item on the list, I used a class (label from Bootstrap) like this:
<span ng-repeat="a in address.addressLines" class="label label-default"> {{ a }} </span>

How to access an element by class in watir

<ul class="navigation">
<li>
<a class="trg-login" href="#">
<i class="icon-dashboard"></i>Login
</a>
Above is my code so how to access the class element in the watir .
Based on the docs, it looks like you'd do this:
myEl = browser.link(:class, "trg-login")
This should select you first element by class in this case selecting class 'navigation'
browser.uls(:class => "navigation")[0]