locked
How to put server side processed code in between header and footer RRS feed

  • Question

  • User238457982 posted


    Hello,
    will someone please help..... I am trying to fill out the main content with information that comes from server by the following coding ( some excerpts):


    ....

    Response.Write("<div id='content' class='resume' style = ';     margin-left: 256px; z-index: 5; width: 440px; height: 500px; top: 130px; left: 170px;'>");
                foreach (XmlNode xn in xnList)
                {

                    string Link = xn["link"].InnerText;
                    string Title = xn["title"].InnerText;
                    string Desc = xn["description"].InnerText;
                    string date = xn["pubDate"].InnerText;
                    Response.Write("<a href=" + Link + ">" + Title + "</a>" + " <br>");
                    Response.Write(date + "<br>");
                    Response.Write(Desc);   
                }
                Response.Write("</div>");

    ...........

    Please see attched picture, which shows what is going on---content is not falling in between header and footer.
    What am I doing wrong? Why my code cannot put the processed information in between header and footer? I did not change original css and original master file.


    The code for for frontend form file is:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Default.master"
    AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

    <asp:content id="Content1" contentplaceholderid="Main" runat="server">

    <div id="resume">
    <div id="content">
    <br /><br />
    <asp:DropDownList ID="DDNewsType" runat="server" Width="200px"
            CausesValidation="True">
                 <asp:ListItem Value="usnews">US National</asp:ListItem>
                 <asp:ListItem Value="topstories">Top Stories</asp:ListItem>
                 <asp:ListItem Value="politics">Politics</asp:ListItem>
                 <asp:ListItem Value="technology">Technology</asp:ListItem>
                 <asp:ListItem Value="business">Business</asp:ListItem>

             </asp:DropDownList>
    <br /><br />
    <asp:Button ID="SelectNews" runat="server" Text="Submit" Height="22px"
                 Width="50px" onclick="Page_Load" />
     
     
     </div>
    </div>


    Please help or give some clues.Thank you.Image describes the problem that content does not go in between header and footer

    Image describes the problem that content does not go in between header and footer

    Thursday, December 3, 2009 9:53 PM

All replies

  • User-1659704165 posted

    String strMyalue ="";

    strMyalue = ("<div id='content' class='resume' style = ';     margin-left: 256px; z-index: 5; width: 440px; height: 500px; top: 130px; left: 170px;'>");
                foreach (XmlNode xn in xnList)
                {

                   strMyalue = strMyalue +  xn["link"].InnerText;
                   strMyalue = strMyalue + xn["title"].InnerText;
                   strMyalue = strMyalue + xn["description"].InnerText;
                   strMyalue = strMyalue +  xn["pubDate"].InnerText;
                   strMyalue = strMyalue +("<a href=" + Link + ">" + Title + "</a>" + " <br>");
                   strMyalue = strMyalue + (date + "<br>");
                    strMyalue = strMyalue +(Desc);   
                }
               strMyalue = strMyalue +("</div>");

    //know have label control which woul allow show the Info in particualr place..

    label1.text = strMyalue;

    strMyalue = "":

    Thursday, December 3, 2009 11:11 PM
  • User238457982 posted

    Hi,

    I cannot have label as I am processing multiple/random rss files. Do you know why my content does not appear inside

    header and footer?

    If I cannot get answer here, I have to make my own template instead of this personal site starter kit template as I think

    I am not understanding something about this template's div and css order. Please someone give me some clues or give

    me solution as I wish to use this personal starter kit templa


    Please click the following url to see the design problem I am describing:

    http://cid-c2aece75ad392191.skydrive.live.com/self.aspx/New%20album/error.jpg

    Thursday, December 3, 2009 11:46 PM
  • User2069888697 posted

    Off the top of my head, it could be that your creating the div dynamically, try putting the code in pre-render. It probaby has somthing to do with the render order.

    Another solution wouls be to give the outer div a static Height like 500px

    <

    div id="content" style="height:500px;">

    then change to

     Response.Write("<div id='content'  style = 'overflow:scroll;; margin-left: 256px; z-index: 5; width: 440px; height: 400px; top: 130px; left: 170px;'>");

    This will work but may not be what you want

    Sunday, December 6, 2009 10:53 AM
  • User2069888697 posted

    Ok I just ran a scenerio which recreated your issue, I then moved it to a prerender, changed the

    <div id="content" >

    to

    <div id="content" runat="server">

     

     Then modified the code to this,tested it and it works fine. As you can see I am simply buiding the html as a string then appling it to the innerhtml of the div.

     

     protected void  Page_PreRender(object sender, System.EventArgs e) 
    { 
        
            string test = ""; 
        for (I = 1; I <= 20; I++) { 
            test = test + ("Test data.") + " <br>"; 
            test = test + "ddddd" + "<br>"; 
            test = test + "mmmmmmmm" + "<br>"; 
        } 
        content.InnerHtml = test; 
    } 
    }


     

     

    Sunday, December 6, 2009 12:01 PM
  • User238457982 posted

    Thank you for your reply. I am so late in reply as I did not log in to this account for last two days. I will definitely try your suggestions; however, I am now in the process of creating my own design template instead of asp net starter kit site and in my own design template, the above problem got solved. I will try out your solution in next 2 days. Please see the result by clicking the following image

    http://cid-c2aece75ad392191.skydrive.live.com/self.aspx/New%20album/myweb.jpg

    that i got from my own design template.


    The main coding portion for the yahoo news in master page is:


    //news
            XmlDocument xmln = new XmlDocument();
            string loadfile = @"http://rss.news.yahoo.com/rss/tech";
            xmln.Load(loadfile);


            XmlNodeList xnnList = xmln.SelectNodes("/rss/channel/item");
            Response.Write("<div id='box3header' style='font-family:Sans-Serif;font-size:11px;;width:340px;height:auto;top:100px;left:600px;z-index:22; color:White;  '>");
            Response.Write("<h3>Yahoo Technology News</h3></div>");
            Response.Write("<div id='box3' style='overflow:auto; font-family:Sans-Serif;font-size:9px;;width:340px;height:220px;top:130px;left:602px;z-index:12; color:White;'>");
           // Response.Write("<h3>Yahoo Technology News<h3>");
            foreach (XmlNode xn in xnnList)
            {

                string Link = xn["link"].InnerText;
                string Title = xn["title"].InnerText;
                string Desc = xn["description"].InnerText;
                string date = xn["pubDate"].InnerText;
                Response.Write("<a href=" + Link + ">" + Title + "</a>" + " <br>");
                Response.Write(date + "<br>");
                Response.Write(Desc + "<br>");
            }
            Response.Write("</div>");
            Response.Write("<div id='box3footer' style='font-family:Sans-Serif;text-indent:300px;font-size:8px;;width:340px;height:auto;top:348px;left:600px;z-index:9; color:White;'>");
            Response.Write("&nbsp;&nbsp;&nbsp;<a href='currentNews.aspx'>More</a></div>");


    It works fine. The news content is in between header and footer. I am not sure why I was not able to put the Yahoo news in between header and footer of asp .net starter kit template, but now I will try your suggestion to understand what I did not understand and will keep you posted. thank you again




    Wednesday, December 9, 2009 12:04 AM