How to separate data items in Repeater? - repeater

I'm using a Repeater
<asp:Repeater runat="server" ID="rpt">
<ItemTemplate>
<asp:Label Text='<%# Eval("History_Info") %>'</asp:Label>
</ItemTemplate>
</asp:Repeater>
The results that I get from DataSource are list of strings.
ex:
Date:08/07/2014, User: UserName, LoginNumber: 000 ......
How can I show it like that :
Date: 08/07/2014
User: UserName
LoginNumber: 000
Thanks

Try doing a replace during binding, so that commas are replaced with line breaks, like so:
<asp:Label Text='<%# ((string)Eval("History_Info")).Replace(",", #"<br/>") %>'</asp:Label>
This will throw error if History_Info is null, so you need to handle that as well, perhaps by using null-coalescing operator (??) or an explicit check.

Related

Is there any way to parse value from this HTML code using XPath?

So, I was trying to get some data out of this HTML code:
<span class="info-icon" data-toggle="popover" data-trigger="hover" title="" data-content="
Рейтинг: <b>4.55/5</b><br/>
Относительно остальных произведений: <b>3.58/5</b><br/>
Всего голосов: <b>62</b>
" data-original-title="Информация о рейтинге">
<i class="fa fa-info-circle"></i>
</span>
I was trying to get whole text using something like this:
//span[#class='info-icon']/#data-content
//span[#data-content='Рейтинг']
//span/#data-content
//span[#class='info-icon']/#data-content
I want to have an output like this:
4.55/5
3.58/5
62
Or atleast like this:
Рейтинг: <b>4.55/5</b><br/>
Относительно остальных произведений: <b>3.58/5</b><br/>
Всего голосов: <b>62</b>
But I'm not getting anything.
P.s. Website URL can be any manga here: http://readmanga.me/
For example http://readmanga.me/tower_of_god
you will need to scrape the source code directly like:
=ARRAYFORMULA(REGEXREPLACE(REGEXREPLACE(QUERY(ARRAY_CONSTRAIN(IMPORTDATA(
"http://readmanga.me/tower_of_god"), 2000, 1),
"where Col1 matches 'Рейтинг:.*|.*остальных произведений:.*|Всего голосов:.*'", 0),
"[А-Яа-я<>br: ]", ),
"//$|/$", ))
The following xpath expressions should probably work:
tokenize(//span/#data-content,' ')[2]
selects
4.55/5
This one:
substring-before(tokenize(//span/#data-content,'<b>')[3],' ')
selects
3.58/5
and this one:
tokenize(//span/#data-content,'<b>')[4]
selects:
62

Match inputs of two text fields

Scenario: I have two input fields. One of them will accept an input in form which the user will decide. The other field should match the format defined in first field. For example, if the user enters format like anan-xxx in the first field..:
The user is allowed to enter b1c1-!*> in the other field.
User cannot enter 1b1c->!* because the first character is expected to be an alphabet not number.
So the first field will define a format definition for a (alphabets), n (numbers), a placeholder, and x (any characters).
What is the easy way to perform this in UI5? I read something related to mask input but I am not sure how to implement it.
As you already guessed, the control sap.m.MaskInput can be leveraged for this kind of use case.
Here is a demo:
globalThis.onUI5Init = () => sap.ui.require([
"sap/ui/core/mvc/XMLView",
"sap/ui/model/json/JSONModel",
"sap/ui/core/Core",
], async (XMLView, JSONModel, core) => {
"use strict";
const control = await XMLView.create({
definition: `<mvc:View
xmlns:mvc="sap.ui.core.mvc"
xmlns:form="sap.ui.layout.form"
xmlns="sap.m"
xmlns:core="sap.ui.core"
core:require="{ StringType: 'sap/ui/model/type/String' }"
height="100%"
>
<App>
<Page showHeader="false">
<form:SimpleForm
editable="true"
layout="ColumnLayout"
>
<Label text="Mask"/>
<Input
value="{
path: '/maskValue',
type: 'StringType',
constraints: {
search: '^$|^[-9ax]+$'
}
}"
placeholder="Example: a9a9-xxx (case sensitive)"
/>
<Label
text="Masked Input"
displayOnly="{= !%{/maskValue}}"
/>
<MaskInput
mask="{/maskValue}"
editable="{= !!%{/maskValue}}"
>
<rules>
<MaskInputRule
maskFormatSymbol="x"
regex="[^_]"
/>
</rules>
</MaskInput>
</form:SimpleForm>
</Page>
</App>
</mvc:View>`,
models: new JSONModel(),
});
core.getMessageManager().registerObject(control, true);
control.placeAt("content");
});
<script id="sap-ui-bootstrap"
src="https://sdk.openui5.org/nightly/resources/sap-ui-core.js"
data-sap-ui-libs="sap.ui.core,sap.m,sap.ui.unified,sap.ui.layout"
data-sap-ui-async="true"
data-sap-ui-oninit="onUI5Init"
data-sap-ui-theme="sap_horizon_dark"
data-sap-ui-compatversion="edge"
data-sap-ui-excludejquerycompat="true"
data-sap-ui-xx-waitfortheme="init"
></script>
<body id="content" class="sapUiBody sapUiSizeCompact"></body>
MaskInput has an aggregation named <rules> which awaits n-MaskInputRules.
sap.m.MaskInput contains already two default rules:
"9" for /[0-9]/
"a" for /[a-zA-Z]/
Additional rule added: "x" for any characters excluding the default placeholder symbol (_). The corresponding regex is /[^_]/.
For further references, take a look at "Writing a regular expression pattern".
Optionally, you could apply the mask in the second Input only when the first Input has passed its value to the model successfully. For this, you could validate the entry via String type with the search constraint regex ^$|^[-9ax]+$ which allows..:
^$: empty string
|: or
^[-9ax]+$: from the beginning (^) till the end (+$), only -, 9, a, or x.
And finally, let the framework handle UI Messages and ValueState in order to make any invalid inputs visible to the user.

Regex in google link params

I do not have experience with regex code.
I want take from following text
http://news.google.com/news/url?sa=t&fd=R&ct2=it&usg=AFQjCNG4x7juUilTtEDL5ae1ecsNh7E-yQ&clid=c3a7d30bb8a4878e06b80cf16b898331&cid=52778905305151&ei=2_utVbj7MsHS1QaH3YHQBA&url=http://time.com/3964691/yoga-dogs-and-cats/ tag:news.google.com,2005:cluster=http://time.com/3964691/yoga-dogs-and-cats/ Mon, 20 Jul 2015 17:44:50 GMT <table border="0" cellpadding="2" cellspacing="7" style="vertical-align:top;"><tr><td width="80" align="center" valign="top"><font style="font-size:85%;font-family:arial,sans-serif"><img src="//t0.gstatic.com/images?q=tbn:ANd9GcSPm8SUGKyWdqCih-LdFBEVfcJI2B86tVNolZJLoeWesaK1Jss7lbJsPKhaqLe8Pap7kYdL2Xw" alt="" border="1" width="80" height="80"><br><font size="-2">TIME</font></font></td><td valign="top" class="j"><font style="font-size:85%;font-family:arial,sans-serif"><br><div style="padding-top:0.8em;"><img alt="" height="1" width="1"></div><div class="lh"><b>Watch <b>cats</b> and dogs interrupt yoga routines - Time</b><br><font size="-1"><b><font color="#6f6f6f">TIME</font></b></font><br><font size="-1">The compilation above shows many a yoga routine getting interrupted. And it really never gets old watching a dog rush to the aid of his owner trapped in a headstand or for a a pet to think pigeon pose is an invitation for kisses. There's also the <b>cat</b> <b>...</b></font><br><font size="-1"><b>Cats</b> And Dogs Interrupting Yoga - Huffington Post UK<font size="-1" color="#6f6f6f"><nobr>Huffington Post UK</nobr></font></font><br><font size="-1" class="p"></font><br><font class="p" size="-1"><a class="p" href="http://news.google.com/news/story?ncl=dtJjhOioeLRtSJMzD7u9ebMAVfF0M&ned=it&hl=en"><nobr><b>tutte le notizie (3) »</b></nobr></a></font></div></font></td></tr></table>
the following string present in the text above
http://time.com/3964691/yoga-dogs-and-cats/
You can get this text using
(?<=url=)http[^\s"]+
See demo
Note that your (?<=url=).+?(?= ) regex matches more than the URL you need to extract:
Try this:
(?<=url=).+?(?= )
Play around with it here: https://regex101.com/r/pO4cT3/1

CFdump and Bootstrap tooltips fight each other

I attach Bootstrap tooltips via
$("[title]").tooltip({ html: true });
When I use a <cfdump>, title tags are attached all over the place. The start of the <cfdump> html looks like this
<table class="cfdump_struct">
<tr><th class="struct" colspan="2" onClick="cfdump_toggleTable(this);" style="cursor:pointer;" title="click to collapse">struct</th></tr>
<tr>
<td class="struct" onClick="cfdump_toggleRow(this);" style="cursor:pointer;" title="click to collapse">Cause</td>
<td>
Is there a way to keep, the two from stepping on eachother?
You shouldn't care because cfdump shouldn't be used in production, however you could just reduce the array returned by the jQuery selector. Not sure if this is the best way to do it, but it works:
$("[title]").filter(function(){
return ($(this).closest(".cfdump_struct").length == 0);
}).tooltip({ html: true });
It runs the filter function for each item in the array returned by the selector. If it is within the CFDUMP table (signified by the .cfdump_struct class) it will not return it. You will have to extend this to other cfdump types (queries, etc) but this should get you started.
Again, it really shouldn't matter since you shouldn't be using cfdump in production code anyway.
You can see this in action here: http://jsfiddle.net/seancoyne/rc7TL/

removing blank lines in htmlText for textarea

I have htmltext as
<p>Here is what some pupils told me about how they prepared for and fared in yesterday's preliminary round.</p>
<hr />
<p>"I will stay calm and try my best. If I do not know a word, I will just have to put something down."</p>
<p><strong>some text</strong></p>
<hr />
<p>"I am more confident than last year because I have experience. I read the newspaper and I looked through the dictionary for difficult words and tagged them."</p>
<p><strong>some text</strong></p>
<hr />
I am displaying the same as textarea.htmlText .
But the textarea displays the above with too many blank lines in between them. Is there a way i can remove the line breaks in the text? the text is coming as it is from server side.
Style the p tag in CSS.
Example:
p{
line-height:0.5;
}