Changing ContentPlaceHolder's content dynamically

Tartar

I have an index page as a content page and at the top of it i have a content place holder like this.

    <asp:Content ID="Content3" ContentPlaceHolderID="logProcessHolder" runat="server">
        <p class="header-link"><a href="LoginFormContainer.aspx">login</a>&nbsp;or&nbsp;<a href="RegisterFormContainer.aspx">create an account</a></p>
    </asp:Content>

I want to change its content when users login. After login i want to put user name instead of these links. I have my login method already, just want to know how can i make this without using an another content page ? or is it a logical solution for me ? Should i use an another content page as a home page ?

Jon P

I would wrap your options in asp:Panels or use the LoginView control as epaezr has done

<asp:Content ID="Content3" ContentPlaceHolderID="logProcessHolder" runat="server">
   <asp:Panel ID="pnlAnonymous" runat="server">
    <p class="header-link"><a href="LoginFormContainer.aspx">login</a>&nbsp;or&nbsp;<a href="RegisterFormContainer.aspx">create an account</a></p>
   </asp:Panel>
   <asp:Panel ID="pnlVerified" runat="server">
       <asp:Literal ID="litUserName" runat="server" />
   </asp:Panel>
</asp:Content>

Then in your code behind

protected void Page_Load(object sender, EventArgs e)
{
    if (Request.IsAuthenticated)
    { 
        pnlAnonymous.Visible = false;
        pnlVerified.Visible = true;
        litUserName.Text = Context.User.Identity.Name;
    }
    else
    {            
        pnlAnonymous.Visible = true;
        pnlVerified.Visible = false;
    }
 }

You don't have to use panels. You could also HTML elements and access them in the code-behind by giving them an ID and a runat="server" attribute. E.g: <p ID="loginLinks" runat="server" class="header-link">...etc...</p> where you could change the visibility with loginLinks.Visible

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Changing ContentPlaceHolder's content dynamically

From Dev

Dynamically changing content of ContentControl via trigger

From Dev

How to dynamically changing content and styling of a web page?

From Dev

send content of dynamically changing div to database

From Dev

Changing content dynamically in WPF window from UserControl

From Dev

Changing the tableview's content inset

From Dev

Dynamically changing innerText's start without eval()

From Dev

Dynamically changing NSWindow's isMovableByWindowBackground and isMovable

From Dev

Dynamically changing UserControl content at run time with WPF/MVVM

From Dev

Changing heights of multiple divs dynamically depending on div with more content

From Dev

Dynamically changing angular-tooltips content on form errors

From Dev

Dynamically changing angular-tooltips content on form errors

From Dev

Changing the data-content of popover dynamically using Jquery / Javascript

From Dev

Dynamically changing content with AngularJS directive, factory, and ng-repeat

From Dev

An updatepanel outside of contentplaceholder in master page causes post back to content page

From Dev

Changing a pane's content from within?

From Dev

Changing the fieldtype of Content in Silverstripe's SiteTree

From Dev

Save control's content after changing template

From Dev

JQuery Dialog's CSS content will remain when changing pages

From Dev

asp.net, showing the content of two contentplaceholder in different divs at the same time

From Dev

How do I dynamically size UICollectionViewCell's height based on content?

From Dev

Dynamically changing functions scala

From Dev

Dynamically changing the sequence of a loop

From Dev

Changing Imageview on button dynamically

From Dev

QScrollArea with dynamically changing contents

From Dev

Changing variable names dynamically

From Dev

Changing CSS dynamically AngularJS

From Dev

Changing a Toolbar appearance dynamically

From Dev

Bokeh dynamically changing BoxAnnotation

Related Related

  1. 1

    Changing ContentPlaceHolder's content dynamically

  2. 2

    Dynamically changing content of ContentControl via trigger

  3. 3

    How to dynamically changing content and styling of a web page?

  4. 4

    send content of dynamically changing div to database

  5. 5

    Changing content dynamically in WPF window from UserControl

  6. 6

    Changing the tableview's content inset

  7. 7

    Dynamically changing innerText's start without eval()

  8. 8

    Dynamically changing NSWindow's isMovableByWindowBackground and isMovable

  9. 9

    Dynamically changing UserControl content at run time with WPF/MVVM

  10. 10

    Changing heights of multiple divs dynamically depending on div with more content

  11. 11

    Dynamically changing angular-tooltips content on form errors

  12. 12

    Dynamically changing angular-tooltips content on form errors

  13. 13

    Changing the data-content of popover dynamically using Jquery / Javascript

  14. 14

    Dynamically changing content with AngularJS directive, factory, and ng-repeat

  15. 15

    An updatepanel outside of contentplaceholder in master page causes post back to content page

  16. 16

    Changing a pane's content from within?

  17. 17

    Changing the fieldtype of Content in Silverstripe's SiteTree

  18. 18

    Save control's content after changing template

  19. 19

    JQuery Dialog's CSS content will remain when changing pages

  20. 20

    asp.net, showing the content of two contentplaceholder in different divs at the same time

  21. 21

    How do I dynamically size UICollectionViewCell's height based on content?

  22. 22

    Dynamically changing functions scala

  23. 23

    Dynamically changing the sequence of a loop

  24. 24

    Changing Imageview on button dynamically

  25. 25

    QScrollArea with dynamically changing contents

  26. 26

    Changing variable names dynamically

  27. 27

    Changing CSS dynamically AngularJS

  28. 28

    Changing a Toolbar appearance dynamically

  29. 29

    Bokeh dynamically changing BoxAnnotation

HotTag

Archive