asp.net mvc - show content from string with html - html

in my Model I have a string property Feeds with value like that:
<img src="/Images/Company/twitter.png" style="border:0; vertical-align:text-bottom;"/>
<b>
9/29/2010 1:01:33 PM
</b>
<br/>
How to get started building rich #VS2010 #VSPackage based extensions -
<a href="http://bit.ly/a8ksc1" target="_NEW">
http://bit.ly/a8ksc1
</a>
<br/> <br/>
<img src="/Images/Company/twitter.png" style="border:0; vertical-align:text-bottom;"/>
<b>
9/3/2010 9:51:26 AM
</b>
<br/>
Windows Phone 7 – Released To Manufacturing
<a href="http://bit.ly/a7HHvw" target="_NEW">
http://bit.ly/a7HHvw
</a>
<br/> <br/><br/>
<img src="/Images/Company//rss.png" style="border:0; vertical-align:text-bottom;"/>
RSS feed to busy :-(
<br/>
How can I show it like html in my view??
I can get it out in textArea, but i want to just to show it like html.
<%= Html.TextAreaFor(obj => obj.Feeds, 60, 40, null) %>

<%= Model.Feeds %>

you can use
<%=Html.Encode(Model.Feeds)%>
this will encode ur tags to html equivalent codes and they will not be interpreted when rendering them on the web page.

Related

Angular *ngFor problems on showing result

i'm trying to show tags from user, (example when user write #name).
my code in html is this.
<div *ngIf="tagsArr" style="display: flex;">
<p>
<span>Tags: </span>
</p>
<p *ngFor="let tag of tagsArr">
<span> {{tag}}, </span>
</p>
</div>
This is the code. and the result is like:
Tags: #name ,#name ,#name < / p >,
(without space)
Why the end tag of </p>, is displayed there?
I want to display the Tags like:
Tags: #name, #name, #name
it shouldn't show <p> may be you have a <p> string in tagsArr
it work fine on my device
.ts
tagsArr = ['#tag1, #tag2, #tag3' ,'#tag4' ]
.html
<div *ngIf="tagsArr">
<p>
<span>Tags: </span>
</p>
<p *ngFor="let tag of tagsArr">
<span> {{tag}}, </span>
</p>
</div>

How to add a link in the end of each element (string) from the list? Using Thymeleaf

I am fetching lines of text from the list one by one and I need to add a hyper link in the end of each line. Trying the code below, but link is not displayed.
<p th:each="releases : ${release}"
class="releases" th:text="${releases}" th:href="www.abc.com"> New Releases </p>
<p th:each="releases : ${release}"> <span class="releases" th:text="${releases.split('Spotify')[0]}">
New Releases </span> <a class="spoturl" th:href="${releases.split('URL:\s')[1]}"> Spotify URL </a> </p>
My solution
If you want to add a link to the end of each "release" string, you can use this:
<p th:each="releases : ${release}"
class="releases">
<span th:text="${releases}"></span>
<a th:href="#{www.abc.com/${rel}(rel=${releases})}"
th:text=" '[link]'"></a>
</p>
So, for example, if the items in the release list are Some_Release and Another_Release, you will get this:
Some_Release [link]
Another_Release [link]
Each link text will have a customized href.
Try this
<p th:each="releases : ${release}" th:href="www.abc.com"> <span class="releases" th:text="${releases}"> New Releases </span> </p>

How to scrape mailto from following page using VBA

i am trying to scrape mailto (href) from a html file, but i am unable to "hit" it.
Any advice is welcome.
<div class="exhibitor-contact">
<div class="col">
<h3>
whatever </h3>
<p>
MLW <br /> whatever<br /> 75008 Paris - France </p>
<p>
<a class='inverse-a-span' href='#tel' id='tel' onclick="return xt_click(this,'C', xtn2, xtpage.replace(/\w*$/, 'exhibitor::tel').replace(/^Exhibitors::/, ''), 'A')">Show Phone Number</a><span style='display:none;'>whatever</span><br /> Send an Email<br /> </p>
</div>
</div>
</section>
Code:
Set my_data = IE.Document.getElementsByClassName("anyclass")
Set mail = IE.Document.getElementsByTagName("a")(0) ActiveSheet.Cells(i, 2).Value = mail.href
Use a css attribute = value selector with ^ starts with operator
Debug.Print ie.document.querySelector("[href^='mailto:']").href

Why does only one image from the two render?

With the following markup, I always get the same look as when for an image that isn't found: its alt and title still there but no pic.
<div class="def-orange">
<h3>Sign Up</h3>
<p>
Which kind of profile would you like?
</p>
</div>
<a href="#Url.Action("RegisterSenior", "Account", new RouteValueDictionary {{"userSide", "contractor" }})">
<img src="images/signup-contractor.png" alt="mans's head sillouheted with safety helmet" title="As a Senior">
</a>
<a href="#Url.Action("RegisterEmployer", "Account", new RouteValueDictionary {{"userSide", "employer" }})">
<img src="/Images/signup-employer.png" alt="mans's head sillouheted with collar and tie" title="As an Employer">
</a>
<div class="def-orange">
Already have an account? #Html.ActionLink("Sign In", "Login", "Account")
</div>
I know both images are present because I can swap them around, and both images display when they are on the right hand one of the two a tags, and neither displays when they are in the left hand a tag.
Change images/signup-contractor.png to /Images/signup-contractor.png

If statement in HTML

Hello i have list of products this my html
<telerik:RadListBox ID="RadListBox1" runat="server" DataSourceID="LinqDataSourceCategories" Height="200px" Width="250px" CssClass="ui-droppable" >
<EmptyMessageTemplate>
No records to display.
</EmptyMessageTemplate>
<ItemTemplate >
<div class="ui-draggable ui-state-default" data-shortid="<%#Eval("ID")%>">
<em>Active : </em><span><%# Eval("LoadProduct") %></span><br />
<em>ProductId: </em><span><%# Eval("ProductId") %></span><br />
</div>
</ItemTemplate>
</telerik:RadListBox>
I have Active that is say if LoadProduct true or false
in client it look like this
<em>Acrive : </em>
<span>False</span>
<br>
<em>ProductId: </em>
<span>101-01-056-02</span>
<br>
<em>ShortID: </em>
<span class="ShortID" data-shortid="0">0</span>
<br>
I want to replace text with img ,i need to check if <%# Eval("LoadProduct") %> ==true put img scr=/green.png/ else img scr=/red.png/ that clien will look like this
<em>Acrive : </em>
<span><img src='green.jpg'/></span>
<br>
<em>ProductId: </em>
<span>101-01-056-02</span>
<br>
<em>ShortID: </em>
<span class="ShortID" data-shortid="0">0</span>
<br>
Sow how it can be done?
To add if statement to HTML,
or to catch event that building all elements and there check if LoadProduct==true and append html to item?
try this
<em>Active : </em><span><%# Convert.ToBoolean(Eval("LoadProduct")) ? "<img src='green.jpg'/>" : "<img src='red.jpg'/>"%></span><br />
Come to think of it, I don't really like the idea of back-end conditionals in front-end.
Code-behind is one thing and frontside is the other - it's not a good idea to mix it if it isn't inevitable.
The purest way to get that would be to set the variable (or a function, in your case) in code-behind and just to show it in front-end, like:
Code behind:
protected string GreenOrRed(bool isLoadProduct)
{
return isLoadProduct ? "green" : "red";
}
(the function or variable has to be at least protected in order to be accessible in aspx page, because the aspx page is the derivative from base class of aspx.cs )
front-end:
<span><img src='<%# GreenOrRed((bool)Eval("LoadProduct")) %>.jpg'/></span>
After that, remeber to add
this.DataBind();
in your Page_Load() function.
Let the code-behind decide, let the front-end only show the result.
<%
if((bool)Eval("LoadProduct") == true)
{
Response.Write("src='green.jpg'");
}
else Response.Write("src='red.jpg'");
%>
Try this
<img src='<%# (bool)Eval("LoadProduct") ? "green.jpg" : "red.jpg" %>'/>