How can I create a column from a text field (using symbol separation) - asp.net

`<div class="form-group">
<div class="col-md-3">
<nop-label asp-for="YearSerial" />
</div>
<div class="col-md-9">
<div class="form-text-row">#Model.YearSerial</div>
</div>
</div>`
This is my code. It's showing line below
Year Serial: 2022;2021;2020
But I need to show every year serial separated by semicolon as a column as below
Year Serial:
2022your text
2021
2020
or It will be great if you can put the year serial in table column
Thanks in advance

Related

Is it possible to to get an empty string in a list when there is no element, using CSS selector?

I want to scrape some items, which are on the same page, using Scrapy.
HTML looks like this:
<div class="container" id="1">
<span class="title">
product-title1
</span>
<div class="description">
product-desc
</div>
<div class="price">
1.0
</div>
</div>
I need to extract name, description and price.
Unfortunately, sometimes product doesn't have the description and HTML look like this:
<div class="container" id="2">
<span class="title">
product-title2
</span>
<div class="price">
2.0
</div>
</div>
Currently I am using CSS selectors which returns list of all elements existing on the website:
title = response.css('span[class="title"]').extract()
['product-title1', 'product-title2', 'product-title3']
description = response.css('div[class="description"]').extract()
['desc1','desc3']
price = response.css('div[class="price"]').extract()
['1.0','2.0','3.0']
Is it possible to get for example an empty string in place of missing 'desc2' when description object isn't there, using CSS selector?
I recommend you to rewrite you code:
for section in response.xpath('//div[#class="container"]'):
title = section.xpath('./span[#class="title"]/text()').get(default='not-found') # you can use any default value here or just empty string
desctiption = section.xpath('./div[#class="description"]').get()
price = section.xpath('./div[#class="price"]/text()').get()
Check this out..
for section in response.xpath('//div[#class="container"]'):
title = section.xpath('./span[#class="title"]/text()').get()
desctiption_tag = section.xpath("//div[contains(#class,'description')]")
if desctiption_tag:
desctiption = section.xpath('./div[#class="description"]').get()
else:
desctiption = "String"
price = section.xpath('./div[#class="price"]/text()').get()

Body is empty except when looking into "history"

Whenever I send an email using a form all of the data get's added correctly however it's not showing up in the "main" email.
Weird split up
Apparently the mail get's split in a main portion and an extra History portion which I need to explicitly click in order to open it.
Another issue I got is that it does send the email to certain emails but ignores certain others without any errors.
Main issue is the text not being shown properly though. Any Ideas?
P.S: sorry for image not showing everything don't want to spread around email addresses.
Another issue, mail only gets send when logged in as admin.
Mail tab
Image
Coding part:
<div class="form-group row mb-1">
<label class="col-sm-2 col-form-label">Naam *</label>
<div class="col-sm-10">[text* your-name akismet:author class:form-
control]</div>
</div>
<div class="form-group row mb-1">
<label class="col-sm-2 col-form-label">E-mail *</label>
<div class="col-sm-10">[email* your-email akismet:author_email class:form-control]</div>
</div>
<div class="form-group row mb-1">
<label class="col-sm-2 col-form-label">Onderwerp</label>
<div class="col-sm-10">[text your-subject class:form-control]</div>
</div>
<div class="form-group row mb-3">
<label class="col-sm-2 col-form-label">Bericht</label>
<div class="col-sm-10">[textarea your-message class:form-control]</div>
</div>
<div class="form-group row">
<div class="offset-sm-2 col-sm-10">[submit class:btn class:btn-primary "Verzenden"]</div>
</div>
And I call the form using [contact-form-7 id="3348" title="Contact form NL"]

Using regular expressions in a css selector

Im scraping a page using Kimono and Ive come across some data that is structured as below.
The issue is that all of the data is stored in an element called <div class="agents-stats-seperator"> some entries only have one of these elements, some have up to 4.
There is different data in each of them that im trying to scrape and the only structured differential between them is the Text, either :
Residential for sale:
Residential for rent:
Commercial for sale:
Commercial for rent:
Im Kimono you have the option to define what you want to select either by css path or regex.
At the moment im defining with the below :
div > div > div > div.agents-stats-seperator > div
/^()(.*?)()$/
Which is causing an issue as it picking up all the <div class="agents-stats-seperator"> elements, what ive been stuck on is how to set the regular expression to target jsut the elements that contain the text Residential for sale:
Ive tried using :
div > div > div > div.agents-stats-seperator > div [str="Residential to rent:"]
/^()(.*?)()$/
But to no avail, any ideas ?
For reference here is a snippet of the html
<div class="clearfix top agents-stats bg-muted">
<div class="agents-stats-seperator">
<div class="agents-stats-l">
Residential for sale:
<strong>14</strong>
</div>
<div class="agents-stats-c">
Avg. asking price:
<strong class="price">£447,143</strong>
</div>
<div class="agents-stats-r">
Avg. sale listing age:
<span>18 weeks</span>
</div>
</div>
<div class="agents-stats-seperator">
<div class="agents-stats-l">
Residential to rent:
<strong>9</strong>
</div>
<div class="agents-stats-c">
Avg. asking rent:
<strong class="price">£1,660 pcm</strong>
</div>
<div class="agents-stats-r">
Avg. rental listing age:
<span>3 weeks</span>
</div>
</div>
<div class="agents-stats-seperator">
<div class="agents-stats-l">
Commercial for sale
<strong>1</strong>
</div>
<div class="agents-stats-c">
Avg. asking price:
<strong class="price">£700,000</strong>
</div>
<div class="agents-stats-r">
Avg. sale listing age:
<span>11 weeks</span>
</div>
</div>
<div class="agents-stats-seperator">
<div class="agents-stats-l">
Commercial to let
<strong>1</strong>
</div>
<div class="agents-stats-c">
Avg. asking rent:
<strong class="price">£22,516 pa</strong>
</div>
<div class="agents-stats-r">
Avg. rental listing age:
<span>56 weeks</span>
</div>
</div>
</div>
Try something like :
div:nth-child(1).agents-stats-seperator > div:nth-child(1).agents-stats-l > strong > a

How to write 4 colums in one row using Thymeleaf th:each

I have a problem with rendering the Pageable response (using Thymeleaf 2.0.19) content to be displayed in rows of <div class="span3">. The row values are dynamic from Spring 3 MVC controller.
Below is the UI code i need to display product images in rows with each row containing 4 cols of span3.
UI snippet to display the product images in 4 cols per row.
<div class="container">
<div class="row-fluid" th:remove="all-but-first">
<div th:each="asset,assetIter : ${page.content}" th:with="numList=${#strings.listSplit('3,2,1,0', ',')}" th:if="${assetIter.index}%4 == 0" class="span3">
<div class="col-sm-6 col-md-3">
<div class="thumbnail">
<span><img src="../abc.png" /></span>
<div class="caption">
<p>Label1 : <span th:text="${asset.id}">Id</span></p>
<p>Label2: <span th:text="${asset.name}">Name</span></p>
<p>Label3: <span th:text="${asset.category}">Category</span></p>
</div>
</div>
</div>
</div>
</div>
</div>
I tried one of the post responses from "Younghan Kim" posted at in thymeleaf, how can write th:each to combine rows and columns?, however i need to display the values from within the page response object which is however String values in the response above.
So, how do i display the above code as rows with 4 cols. Please provide inputs and let me if i am missing out on something as i am new to thymeleaf impl.
Also the UI pagination is implemented on server side as mentioned in the blog below:
http://www.jiwhiz.com/post/2013/2/Implement_Bootstrap_Pagination_With_SpringData_And_Thymeleaf

Loading text onto a webpage using ASP.NET

Which is the best way to load text into a webpage using ASP.NET
I have 3 records in a MS SQL database table. Each record would correspond to a paragraph in a webpage.
Table:
The HTML code for the About us page would look like this (note I put the corresponding paragraphs) :
<div id="content-1b">
<div id="content-1-1b">
</div>
<div id="content-1-2b"><p class="none">paragraph 1</p>
<p class="nonetop">paragraph 2</p>
</div>
</div>
<div id="content-3b"><p class="nonetop">paragraph 3</p>
</div>
Regards,
Tea
Declare these Divs as server controls by giving an unique Id a d runat=server so that you can access the object back in code behind.
These divs are equavilent to HTMLGenericControl so you can just say divid.innerHTML = content.
Or you can also use a repeater and bind to your div
Setting your divs or paragraph tags as runat="server" with an ID will allow you to access innerhtml/text
HTML:
<div id="content-1b">
<div id="content-1-1b">
</div>
<div id="content-1-2b"><p class="none" id="p1" runat="server">paragraph 1</p>
<p id="p2" runat="server" class="nonetop">paragraph 2</p>
</div>
</div>
<div id="content-3b"><p id="p3" runat="server" class="nonetop">paragraph 3</p>
</div>
Running code like: (assuming your content is in a datatable and that you want the first item (0) from each row)
For each row as Datarow in dt
p1.InnerHtml += Row.Item(0).ToString
Next
Will loop through your datatable, get the first column from each row and append the text to the paragraph tag.
Update:
For Single Content
If your SQL returns 3 rows, 1 for each area you want to fill simply do:
Assuming dt is the datatable you are filling and that the first column of each row is your content.
p1.InnerHTML = dt.rows(0).Item(0)
p2.InnerHTML = dt.rows(1).Item(0)
p3.InnerHTML = dt.rows(2).Item(0)

Resources