Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Dynamically Load Content ?

Dynamically Load Content ?

Scheduled Pinned Locked Moved ASP.NET
questioncsharphtmlasp-netwinforms
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Skoder
    wrote on last edited by
    #1

    Hey, i was just wondering about this very basic action. If i have a page which should show some html content if etc the site is not PostBack, and some other html content if PostBack, in old asp you could just do something like ... : <% if (foo) { %> THE HTML CONTENT <% } else { %> SOME OTHER HTML CONTENT <%}%> I know this is also possible in ASP.NET but it is probably not the correct way of doing this (or is it?). Soo how should this be handled in ASP.NET ? My best guess is that the 2 different HTML Contents could etc be put in 2 User controls and then loaded dynamically in the Codebehind. Soo it would be some thing like, .. if (foo) { load one user Control } else { load the other user control } Is it possible to do it without using user controls ? If i have to use usercontrols how do i add them to a specific contentplaceholder (i am using MasterPages asp.net 2.0) ? I havent really been able to find out how to display content dynamically in a contentplaceholder. Hope someone out there is able to help me with some of the problems Martin :confused:

    M M 2 Replies Last reply
    0
    • S Skoder

      Hey, i was just wondering about this very basic action. If i have a page which should show some html content if etc the site is not PostBack, and some other html content if PostBack, in old asp you could just do something like ... : <% if (foo) { %> THE HTML CONTENT <% } else { %> SOME OTHER HTML CONTENT <%}%> I know this is also possible in ASP.NET but it is probably not the correct way of doing this (or is it?). Soo how should this be handled in ASP.NET ? My best guess is that the 2 different HTML Contents could etc be put in 2 User controls and then loaded dynamically in the Codebehind. Soo it would be some thing like, .. if (foo) { load one user Control } else { load the other user control } Is it possible to do it without using user controls ? If i have to use usercontrols how do i add them to a specific contentplaceholder (i am using MasterPages asp.net 2.0) ? I havent really been able to find out how to display content dynamically in a contentplaceholder. Hope someone out there is able to help me with some of the problems Martin :confused:

      M Offline
      M Offline
      MihirV
      wrote on last edited by
      #2

      hi there use Panel Control instead.... :) Confidence comes not from always being right, but from not fearing to be wrong..... Mihir..

      S 1 Reply Last reply
      0
      • S Skoder

        Hey, i was just wondering about this very basic action. If i have a page which should show some html content if etc the site is not PostBack, and some other html content if PostBack, in old asp you could just do something like ... : <% if (foo) { %> THE HTML CONTENT <% } else { %> SOME OTHER HTML CONTENT <%}%> I know this is also possible in ASP.NET but it is probably not the correct way of doing this (or is it?). Soo how should this be handled in ASP.NET ? My best guess is that the 2 different HTML Contents could etc be put in 2 User controls and then loaded dynamically in the Codebehind. Soo it would be some thing like, .. if (foo) { load one user Control } else { load the other user control } Is it possible to do it without using user controls ? If i have to use usercontrols how do i add them to a specific contentplaceholder (i am using MasterPages asp.net 2.0) ? I havent really been able to find out how to display content dynamically in a contentplaceholder. Hope someone out there is able to help me with some of the problems Martin :confused:

        M Offline
        M Offline
        matthias s 0
        wrote on last edited by
        #3

        Hi there,

        Skoder wrote:

        If i have to use usercontrols how do i add them to a specific contentplaceholder (i am using MasterPages asp.net 2.0) ?

        I haven't used 2.0 yet, but I guess the functionality should be identical. Look up the LoadControl method in the MSDN. It takes a virtual directory as a paramter, e.g. Controls/MyControl.ascx. Should solve your problem. Hope that helped. /matthias

        I love deadlines. I like the whooshing sound they make as they fly by.
        [Douglas Adams]

        1 Reply Last reply
        0
        • M MihirV

          hi there use Panel Control instead.... :) Confidence comes not from always being right, but from not fearing to be wrong..... Mihir..

          S Offline
          S Offline
          Skoder
          wrote on last edited by
          #4

          Hi, thanks for the answer. If i have 2 panel controls instead each with its own content, do you have any idea of how i apply that panel to be shown in the contentPlaceholder ? I have tried giving the contentplaceholder a ID, but i dont seem to be able to use it like myPlaceholderID.addContent() for an example... ? any ideas ? how should it be done if isPostBack addpanel1 else addpanel2 ... ?

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups