Dynamically Load Content ?
-
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:
-
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:
-
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:
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. /matthiasI love deadlines. I like the whooshing sound they make as they fly by.
[Douglas Adams] -
hi there use Panel Control instead.... :) Confidence comes not from always being right, but from not fearing to be wrong..... Mihir..
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 ... ?