Jess Wss Jess Wss - 1 year ago 95
ASP.NET (C#) Question

New line javascript or

I want to add a new line in my code so that my files can be under each other. I will post the code from Js and with their link buttons.

$(qFiles).each(function (i)
var a = document.createElement('a');
var isSharePoint = this.isSharePoint;
var img =document.createElement('img') ;
if (isSharePoint) { = "_blank";
a.href = this.FilePath;
img.src = appPath + '/Images/pagelink_16x16.png';

else {
var filePath = this.FilePath;
var fileName = this.FileName;
a.onclick = function() {
downloadFile(filePath + "\\" + fileName);
img.src = appPath + '/Images/download_16x16.png';
a.innerHTML += this.FileName;
a.className = "linkSurrogate singleLine";

qDiv = $(config.jQuerySelectors.quoteFiles);
var dialog = qDiv.dialog({
autoOpen: true,
height: config.dialog.height,
width: config.dialog.width,
closeOnEscape: true,
resizable: false,
title:"Quote "+ quoteNo +" Files",
modal: true,
buttons: {
"Close": function () {

As you can see here is a validation, if is SharePoint or not. And there as well is the dialog where the two files appear.
And here is the code with the link buttons:

<div id="quoteFiles" style="display: none">
<asp:LinkButton CssClass="linkButton" ID="downloadFile" ClientIDMode="Static" runat="server" OnClick="downloadFile_Click"></asp:LinkButton>
<asp:LinkButton CssClass="linkButton" ID="sharePoint" ClientIDMode="Static" runat="server" OnClick="downloadFile_Click"></asp:LinkButton>
<asp:Label runat="server" ID="quoteFiles" ClientIDMode="Static" Text="There are no files attached."></asp:Label>

I already tried with
<br />
and didn't worked. As well I tried to put a new line in the asp page, but nothing seemes to work.

Answer Source

After your code line:


Put this after it:

var p = document.createElement('p');

This will then be written after the link (file -> link -> newline). It will create an empty p tag. You could also append a br tag, but sometimes this doesn't show and then you need 2 br's which are shown as 2 newlines on some browsers and 1 newline on other browsers, so an empty p tag is what you want cause this is always rendered correctly by all browsers.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download