locked
How to change the position of response.write(); RRS feed

  • Question

  • User-366701151 posted

    So this is the view :

    <pre>@model CMSFC.Models.Page

    @{

    Layout = "~/Views/Shared/_Layout.cshtml";
    }

    @{

    Response.Write(Model.Template);
    }


    </pre>


    It renders a html table (saved in Template column) from database , with header footer body and so on .. But this renders a very small table on the top left corner of the application , i want to render that html table on the entire screen of view .

    Wednesday, September 6, 2017 8:49 AM

Answers

  • User347430248 posted

    HI ddgg,

    please try to refer code below.

    Response.Write("<span id='Label1'' style='height:16px;width:120px;Z-INDEX: 102; LEFT: 288px; POSITION: absolute; TOP: 144px; background-color: yellow'>Hello , this is demo text</span>");

    you can try to adjust the height and width according to your requirement.

    Regards

    Deepak

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 14, 2017 3:13 AM

All replies

  • User-1509636757 posted

    From your question description, I understood you wanted to show raw HTML content from database (retrieved in your model CMSFC.Models.Page). If this is correct then I suggest you use HtmlHelper.Raw Method (String) (System.Web.Mvc) as:

    @Html.Raw(Model.Template)

    Wednesday, September 6, 2017 10:22 AM
  • User-366701151 posted

    Okay , now is quite better , but still the output position is in the top left corner , can you help me with that , how to center it , or have the entire page ?!

    Wednesday, September 6, 2017 10:36 AM
  • User-1509636757 posted

    Okay , now is quite better , but still the output position is in the top left corner , can you help me with that , how to center it , or have the entire page ?!

    Can you provide HTML Template value and code of your View?

    Wednesday, September 6, 2017 10:44 AM
  • User-366701151 posted

    This is the view :

    @model CMSFC.Models.Page
     
    @{
        
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
     
     
     
     
     
            @{
     
                if (Model.Template != null)
                {
                    // Response.Write(Model.Template);
                    @Html.Raw(Model.Template)
     
     
                }
     
     
     
            }
     
      
     
     
     
     
     
     
     
    





    And this is the Layout view :

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>@ViewBag.Title - My ASP.NET Application</title>
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
     
    </head>
    <body>
        <div class="navbar navbar-inverse navbar-fixed-top">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
               @*   @Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })*@  
                </div>
                <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li>@Html.ActionLink("Index""Index""Home")</li>
                        <li>@Html.ActionLink("About""About""Home")</li>
                        <li>@Html.ActionLink("Contact""Contact""Home")</li>
                        <li>@Html.ActionLink("News""Index""ContentHtml")</li>
                        @if (User.Identity.IsAuthenticated)
                        {
                            if (User.IsInRole("Admin"|| User.IsInRole("Guest"))
                            {
                                <li>@Html.ActionLink("PageConfig""Index""PageConfigs")</li>
                                <li>@Html.ActionLink("Pages""Index""Pages")</li>
                             
                              
                            }
                        }
                       
     
                    </ul>
                   
                    @Html.Partial("_LoginPartial")
                </div>
            </div>
        </div>
        <div class="container body-content">
            @RenderBody()
            <hr />
            <footer>
                <p></p>
            </footer>
        </div>
     
        @Scripts.Render("~/bundles/jquery")
        @Scripts.Render("~/bundles/bootstrap")
        @RenderSection("scripts", required: false)
    </body>
    </html>
    



    HTML template value differs , but i want that to render in the entire page , not in a small piece.

    Wednesday, September 6, 2017 10:45 AM
  • User347430248 posted

    Hi ddgg,

    did you try to set the position of table where you created it?

    if not you can try to set it as you want in your page.

    it is possible that it is just showing you the table as you design it.

    so if you had design it to display in the top left. it is just showing you there.

    Regards

    Deepak

    Thursday, September 7, 2017 5:54 AM
  • User-366701151 posted

    Hi , 

    No , i didnt do any styling/css , can you provide me a little help , how can i show a table/or a div  in the entire page.

    Thursday, September 7, 2017 7:21 AM
  • User347430248 posted

    HI ddgg,

    please try to refer code below.

    Response.Write("<span id='Label1'' style='height:16px;width:120px;Z-INDEX: 102; LEFT: 288px; POSITION: absolute; TOP: 144px; background-color: yellow'>Hello , this is demo text</span>");

    you can try to adjust the height and width according to your requirement.

    Regards

    Deepak

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 14, 2017 3:13 AM