Jess Wss
Jess Wss

Reputation: 3

New line javascript or asp.net

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 asp.net with their link buttons.

$(qFiles).each(function (i)
                    {
                        var a = document.createElement('a');
                        var isSharePoint = this.isSharePoint;
                        var img =document.createElement('img') ;
                        if (isSharePoint) {
                            a.target = "_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';
                        }
                        qDiv.appendChild(img);
                        a.innerHTML += this.FileName;
                        a.className = "linkSurrogate singleLine";
                        qDiv.appendChild(a);
                    });

                    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 () {
                                qDiv.dialog('close');
                            }
                        }
                    }); 

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>
        </div>

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

Upvotes: 0

Views: 53

Answers (1)

Saskia
Saskia

Reputation: 524

After your code line:

qDiv.appendChild(a);

Put this after it:

var p = document.createElement('p');
qDiv.appendChild(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.

Upvotes: 1

Related Questions