locked
Unique content within master page based on conditions met RRS feed

  • Question

  • User2019633211 posted

     Hi all-

    I would like to present users with unique content based on certain conditions being met as they land on the home page (default.aspx).  The condition logic will be in the VB code behind Page Load event. The content will go in a content placeholder as specificed from the master page. 

    However, the content change wouldn't be something small (ie making a panel or label visible or not) but rather it will be different HTML,  Divs and databound gridview content.  The HTML content will be stored in the database.

    Can someone point me in the right direction for best practices on how to accomplish this?

    Thanks!

    Friday, August 20, 2010 4:01 PM

Answers

  • User-1852462877 posted

    Just did a similar thing, so you want to render HTML directly from your database?

    ASPX Page

    <form id="MyForm" method ="post" runat="server">
           <br />
           <asp:PlaceHolder ID="FromLinks" runat="server" ></asp:PlaceHolder>
           <br />
           <asp:Button ID="btnSearch" runat="server" Text="Button"/><br />
    </form>


    Code Behind Page (VB):

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    	FromLinks.Visible = False 
    End Sub
    
    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
    	LoadFromLinks()                         'Show From Links Placeholder
    End Sub
    
    Public Sub LoadFromLinks()
            FromLinks.Visible = True                'Show FromLinks Placeholder
            Dim totext = "FROM:" _
    	& "<div id=""From"">" _
    	& "<a href=From.aspx?fc=A> A</a>" _
    	& "<a href=From.aspx?fc=Z> Z</a>" _
    	& "<br />" _
    	& "</div>"
            Dim DDLControl As Control
            DDLControl = Page.ParseControl(totext)
            FromLinks.Controls.Add(DDLControl)
    End Sub


    Hope this helps!

    See Ya!


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 21, 2010 2:53 AM
  • User-33420011 posted

    your markup

    <div id="divPage" runat="server" />

    and in code behind

    divPage.InnerHTML = "YOUR CONTENT FROM DB"



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 21, 2010 3:00 AM

All replies

  • User-1852462877 posted

    Just did a similar thing, so you want to render HTML directly from your database?

    ASPX Page

    <form id="MyForm" method ="post" runat="server">
           <br />
           <asp:PlaceHolder ID="FromLinks" runat="server" ></asp:PlaceHolder>
           <br />
           <asp:Button ID="btnSearch" runat="server" Text="Button"/><br />
    </form>


    Code Behind Page (VB):

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    	FromLinks.Visible = False 
    End Sub
    
    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
    	LoadFromLinks()                         'Show From Links Placeholder
    End Sub
    
    Public Sub LoadFromLinks()
            FromLinks.Visible = True                'Show FromLinks Placeholder
            Dim totext = "FROM:" _
    	& "<div id=""From"">" _
    	& "<a href=From.aspx?fc=A> A</a>" _
    	& "<a href=From.aspx?fc=Z> Z</a>" _
    	& "<br />" _
    	& "</div>"
            Dim DDLControl As Control
            DDLControl = Page.ParseControl(totext)
            FromLinks.Controls.Add(DDLControl)
    End Sub


    Hope this helps!

    See Ya!


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 21, 2010 2:53 AM
  • User-33420011 posted

    your markup

    <div id="divPage" runat="server" />

    and in code behind

    divPage.InnerHTML = "YOUR CONTENT FROM DB"



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 21, 2010 3:00 AM
  • User2019633211 posted

    Thank you tanatrajan and CandorZ for that help!

    Saturday, August 21, 2010 3:30 PM