0

When I created a method in a controller I would like the output which is HTML to be displayed in the view. Although I see the functions results as the expected html it does not display in the page.

I've tried the HtmlHelper Html.Raw

       <table class="table table-bordered table-framed" id="seconDTable" style="display:block;height:100%;">
                        <tbody>
                            @if (caseFile.Length > 0 && RenamedCaseFileName.Length > 0)
                            {
                                <tr>
                                    <td style="width: 100%;">
                                        <input type="checkbox" id="CheckBox" title="Select All Bookmarks" onchange="changeCheckBox();" class="styled" />
                                        <span>Select All</span>
                                    </td>
                                </tr>
                                if (oGdPicturePDFstatus == GdPicture14.GdPictureStatus.OK)
                                {

                                    int rootID = oGdPicturePDF.GetBookMarkRootID();
                                    oGdPicturePDFstatus = oGdPicturePDF.GetStat();

                                    if (oGdPicturePDFstatus == GdPicture14.GdPictureStatus.OK)
                                    {
                                        IHtmlString str = new HtmlString(GetPDFBookmarks.ParseBookmarksOutlines(oGdPicturePDF, rootID, 0));
                                        Html.Raw(str);
                                    }
                                    else
                                    {
                                        if (oGdPicturePDFstatus == GdPicture14.GdPictureStatus.PropertyNotFound)
                                        {
                                            <tr>
                                                <td style="width: 100%;">
                                                    This PDF document doesn't contain any bookmarks.
                                                </td>
                                            </tr>
                                        }
                                    }
                                }
                                oGdPicturePDF.Dispose();
                            }
                        </tbody>
                    </table>

Function:

                       public string ParseBookmarksOutlines(GdPicturePDF oGdPicturePDF, int bookmarkID, int level)
                                {
                                    string title = "";
                                    GdPictureStatus status = GdPictureStatus.OK;
                                    string cssType = string.Empty;
                                    string TableRows = string.Empty;
                                    while (true)
                                    {
                                        title = oGdPicturePDF.GetBookMarkTitle(bookmarkID);
                                        status = oGdPicturePDF.GetStat();

                                        if (level == 0)
                                        {
                                            cssType = "ParentsourcefileCheckBox";
                                        }
                                        else
                                        {
                                            cssType = "ChildsourcefileCheckBox";
                                        }

                                        if (status == GdPictureStatus.OK)
                                        {
                                            TableRows = TableRows + "<tr><td style=\"width: 100 %; \">";
                                            TableRows = TableRows + "<input name=\"sourcefileCheckBox\" type=\"checkbox\" class=\"" + cssType + "\" id=\"checkBox\" value=\"" + bookmarkID + "\" />";
                                            TableRows = TableRows + "<span>" + title + "</span>";
                                            TableRows = TableRows + "</td></tr>";

                                        }
                                        else
                                        {
                                            TableRows = TableRows + "<tr><td>";
                                            TableRows = TableRows + "Title: this error occurs - " + status.ToString() + "    Level: " + level.ToString() + "\n";
                                            TableRows = TableRows + "</td></tr>";
                                            //message = message + "Title: this error occurs - " + status.ToString() + "    Level: " + level.ToString() + "\n";
                                        }
                                         if (bookmarkID == 0)
                                        {
                                            break;
                                        }

                                    }

                                    return TableRows;
                                }

I'm expecting the checkboxes to be displayed on the final rendered page instead it does not display ay all.

enter image description here

Carl
  • 17
  • 3

1 Answers1

1

The answer was the following:

 @Html.Raw(HttpUtility.HtmlDecode(GetPDFBookmarks.ParseBookmarksOutlines(oGdPicturePDF, rootID, 0)));

It was located in the post: Return html string from controller and display in view

Carl
  • 17
  • 3