Can someone point me to a sample or tutorial or the code to load pages into a placeholder.
I have a menu bar on the left of the page and am trying to load the clicked pages on the right.
Any ideas,
Cheers
NickWelcome to the ASP.NET forums, Nick.
You may be very interested inUser Controls. (They were originally called Pagelets, since they are very much like you described ... littles pages that you embed within your main page.)
That link is one of theQuickStart Tutorials which you might want to look through.
Hope this helps.
Hmm ive had a read over and im still stuck.
do i include the code in a script block or in the codebehind file??
Umm, neither.
Can you show the code for your page, indicating which part you want to separate out as the menu bar, and which page will have the content loaded into it?
If you do so, can you please post it between<code> and</code> tags?
Here it is.
for the link
<TD>
<a id="goHome" runat="server"><img src="http://pics.10026.com/?src=images/myWebHome.jpg"></a>
</TD>
with goHome.HRef defined in the cs file.<TABLE cellSpacing="10" cellPadding="0" width="100%" border="0">
<asp:placeholder id="PageBody" runat="server"></asp:placeholder>
</TABLE>
I'm trying to get the link to display in the placeholder.
Cheers,
Nick
Why not use frames?
One more question before I can show you an answer.
When you say you are trying to load "pages" into a Placeholder, do you mean anentire webpage inside the table cell? Or do you just want to load differentcontent into the table cell, based on the button the user has clicked?
At the moment it is content contained within an aspx file, so an entire page I guess, what other options are available. I'm a bit of a noob to all this and have to get myself on a steep learning curve. Thanks for all your help and time.
You should really be putting yoursections of content in a User Control (.ascx), Loading them (using Page.LoadControl) when appropriate and then adding them to the PlaceHolder Control. For example:
void Page_Load ( Object src, EventArgs eArgs ) { Control page;
switch ( QueryString [ "page" ] ) {
case "Home" : page = LoadControl ( "/controls/home.ascx" );
break;
case "About" : page = LoadControl ( "/controls/about.ascx" );
break;
...
}
PageBody.Controls.Add ( page );
}
I assume this goes into a <script> block in the actual page. Now how do I pass the param to the switch?
Either in a <script> declaration block or CodeBehind.
The requesting URL would look like:
http://www.domain.com/default.aspx?page=Home
0 comments:
Post a Comment