|
|
||||||
|
#1
|
|
|
|
|
Hi,
i'm trying to build a simple site navigation (using c#)... i implemented a master page that shows a sidebar user control on the left side, and a content page on the right. i click the link on the sidebar which calls Redirect. problem is that the whole page refreshes... i just want the right side to update to a new content. can anyone point me in the right direction to accomplish this? btw, i'm trying to use ajax when possible to make the job easier... but if i put the sidebar in an UpdatePanel (in hopes of avoiding a refresh) it gives this error: "Sys.WebForms.PageRequestManagerParserErrorExcepti on: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write()" Thanks for any info you can give! |
|
|
|
#2
|
|
|
|
|
On Mar 9, 11:26 am, Ben <benm5> wrote:
[..] > > btw, i'm trying to use ajax when possible to make the job easier... > but if i put the sidebar in an UpdatePanel (in hopes of avoiding a > refresh) it gives this error: > > "Sys.WebForms.PageRequestManagerParserErrorExcepti on: The message > received from the server could not be parsed. Common causes for this > error are when the response is modified by calls to Response.Write()" > > Thanks for any info you can give! http://alpascual.com/blog/al/archive...n-in-AJAX.aspx |
|
#3
|
|
|
|
|
On Mar 9, 5:37 am, Alexey Smirnov <alexeysmir> wrote:
> On Mar 9, 11:26 am, Ben <benm5> wrote: >> >> >> >> > > [..] Hide quoted text - > > - Show quoted text - Thanks for the quick response, that solved that error, however the entire page still refreshes.... how do i make it so just the content page (right side) changes to a different web form? if i need to drop master pages i can... just trying to create a clean design, where i have a seperate web form for each page, and the side bar on the left does not refresh. |
|
#4
|
|
|
|
|
"Ben" <benm5678> wrote in message
news:3fe0 >> [..] >> Hide quoted text - >> >> - Show quoted text - > > Thanks for the quick response, that solved that error, however the > entire page still refreshes.... > > how do i make it so just the content page (right side) changes to a > different web form? if i need to drop master pages i can... just > trying to create a clean design, where i have a seperate web form for > each page, and the side bar on the left does not refresh. Sounds like you're making the "classic" mistake with MasterPages by thinking that they are somehow the ASP.NET version of framesets.... MasterPages are nothing at all like framesets... In fact, a MasterPage isn't a page at all - it's little more than a UserControl. If Microsoft had called them LayoutControls instead of MasterPages, this confusion would never have occurred... When a content page is requested, it loads its MasterPage(s) and merges the markup to form a single HTML page which is streamed down to the client, just like any other ASP.NET page... If you don't want this to happen, then you will need to go back to old framesets or, maybe, use an <iframe>. However, I strongly advise you not to even consider this, and to stick with MasterPages... |
|
#5
|
|
|
|
|
On Mar 9, 6:56 am, "Mark Rae [MVP]" <m> wrote:
[..] > > If you don't want this to happen, then you will need to go back to old > framesets or, maybe, use an <iframe>. > > However, I strongly advise you not to even consider this, and to stick with > MasterPages... > > -- > Mark Rae > ASP.NET MVPhttp://www.markrae.net Thanks Mark -- That's why I looked into master pages, since i read that framesets are a thing of the past... but isn't there some solution to just re-load the right side (the content) and leave the left (the menu sidebar) in-tact? It doesn't look professional when the whole page refreshes every time someone clicks a new menu item.... or is the only way to accomplish this using framesets?!? |
|
#6
|
|
|
|
|
"Ben" <benm5678> wrote in message
news:ca67 > Thanks Mark -- That's why I looked into master pages, since i read > that framesets are a thing of the past... > > but isn't there some solution to just re-load the right side (the > content) and leave the left (the menu sidebar) intact? Not with MasterPages... > It doesn't look professional when the whole page refreshes every time > someone clicks a new menu item.... That's the way the web works... > or is the only way to accomplish this using framesets?!? One of the main features of MasterPages is the server-side interoperability between the content pages and MasterPages - you can't really do this with framesets or iframes, so you're left with client-side JavaScript. Obviously, you could create an asp:Literal control and fill it dynamically with HTML, but that would mean that you would lose all of the server-side ASP.NET functionality. I would strongly advise you to stick with MasterPages - once you've got the hang of them, you'll wonder how you ever managed without them... |
|
#7
|
|
|
|
|
On Mar 9, 9:22 am, "Mark Rae [MVP]" <m> wrote:
[..] > Obviously, you could create an asp:Literal control and fill it dynamically > with HTML, but that would mean that you would lose all of the server-side > ASP.NET functionality. > > I would strongly advise you to stick with MasterPages - once you've got the > hang of them, you'll wonder how you ever managed without them... > > -- > Mark Rae > ASP.NET MVPhttp://www.markrae.net yea, i want to avoid dynamically filling the HTML on the client side... i was really hoping for the exact same functionality framesets provided (being able to reload a particular frame), i just thought there's an alternative that would behave in a similar way. u know that MSDN page for the subscriber downloads... it's got a navigation tree on the left, and it doesn't refresh when you click things, just the content pane refreshes... that's what i wanted... maybe they're using framesets... btw, if there's any recommended book u can suggest that covers these topics (i'm using VS 2008 now), let me know, i'd really appreciate it... i think i need to get some basics down. thanks!! |
|
#8
|
|
|
|
|
"Ben" <benm5678> wrote in message
news:542c > You know that MSDN page for the subscriber downloads... it's got a > navigation tree on the left, and it doesn't refresh when you click > things, just the content pane refreshes... that's what I wanted... > maybe they're using framesets... The "content" pages are static HTML stored in a database... BTW, if there's any recommended book you can suggest that covers these topics (I'm using VS 2008 now), let me know, I'd really appreciate it... I think I need to get some basics down. http://www.kencox.ca/ |
|
#9
|
|
|
|
|
It might be easier for you to consider building your side menus into your
content pages instead of the master page. Then you could definitely do partial page updates using nested update panels. Regan "Mark Rae [MVP]" <mark> wrote in message news:6092 [..] |
|
#10
|
|
|
|
|
"Regan" <regan.thomas> wrote in message
news:4880 > > It might be easier for you to consider building your side menus into your > content pages instead of the master page. Then you could definitely do > partial page updates using nested update panels. Apart from the fact that that would totally defeat the purpose of MasterPages... |
|
#11
|
|
|
|
|
On Mar 9, 12:19 pm, "Mark Rae [MVP]" <m> wrote:
[..] >> Apart from the fact that that would totally defeat the purpose of > MasterPages... > > -- > Mark Rae > ASP.NET MVPhttp://www.markrae.net- Hide quoted text - > > - Show quoted text - This is closer to what i need though... i'd rather not use a master page in this section if it forces a full refresh. I''m testing it now... so built a table with 2 columns in a webform, one side has my menu and the other an UpdatePanel. On menu item click I load a new Web User Control into the UpdatePanel using this code: UpdatePanel.ContentTemplateContainer.Controls.Clea r(); UserControl uc = (UserControl)LoadControl(sPathToWebUI); UpdatePanel.ContentTemplateContainer.Controls.Add( uc); It has a strange behavior -- when the contol loads, I click on a button and it doesn't post back... i click again and only then it works... is there anyway to fix this? |
|
#12
|
|
|
|
|
I tried recreating your columns and update panel just to test it. I added a
"parent" update panel that holds everything except the Script Manager. And then I dropped a variation of your code into my button onClick, which created a Textbox control in the right column's Update Panel. As expected, the partial post back worked fine. (with the "parent" Update Panel). I would suggest, breaking through your user control; the two-click bug might be in there. I'm not sure what the code for your control looks like. "Ben" <benm5678> wrote in message news:1c8c [..] |
|
#13
|
|
|
|
|
On Mar 9, 4:13 pm, "Regan" <regantho> wrote:
[..] >> >> >> > - Show quoted text - Thanks for trying it !! ...i still can't figure out what's wrong. The left side holds a menu with 3 items. 2 of them point to almost empty user controls (with just a text heading), the other points to a user control with a heading, a button and a textbox... the onclick of the button has code to simply put the current date in the textbox. If I click on that menu item first, it switches to that page and I can click the button and it posts right away and displays the time... but if i switch to another menu item and then come back to the one with the textbox, it takes 2 clicks to get it to post correctly (when debugging i can see it goes to the main form's Page_Onload and then to the User Control's Page_Onload, but does not proceed to the Button1_Click of the user control). Here's the code, maybe someone sees the problem? Main form table: ---------------------------- <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Table ID="Table1" runat="server" Width="100%"> <asp:TableRow ID="TableRow1" runat="server"> <asp:TableCell ID="TableCell1" runat="server" ColumnSpan="2"><center> <asp:Label ID="Label1" runat="server" Text="Label" CssClass="PageHeader">SIMS Admin Console</asp:Label></center></ asp:TableCell> </asp:TableRow> <asp:TableRow ID="TableRow2" runat="server"> <asp:TableCell ID="TableCell2" runat="server" Width="20%"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Menu ID="Menu1" runat="server" OnMenuItemClick="Menu1_MenuItemClick" > <Items> <asp:MenuItem Text="Load Control1"></asp:MenuItem> <asp:MenuItem Text="Load Control2"></asp:MenuItem> <asp:MenuItem Text="Load Control3"></asp:MenuItem> </Items> </asp:Menu> </ContentTemplate> </asp:UpdatePanel> </asp:TableCell> <asp:TableCell ID="TableCell3" runat="server"> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> </ContentTemplate> </asp:UpdatePanel> </asp:TableCell> </asp:TableRow> </asp:Table> Main Form Code: ------------------------------ private const string BASE_PATH = "~/"; protected void Page_Load(object sender, EventArgs e) { LoadUserControl(); } protected void Menu1_MenuItemClick(object sender, MenuEventArgs e) { MenuItem menu = e.Item; string controlPath = string.Empty; switch (menu.Text) { case "Load Control2": controlPath = BASE_PATH + "WebUIClientSummary.ascx"; break; case "Load Control3": controlPath = BASE_PATH + "WebUIConfigSummary.ascx"; break; default: controlPath = BASE_PATH + "WebUIMainSummary.ascx"; break; } LastLoadedControl = controlPath; LoadUserControl(); } private string LastLoadedControl { get { return ViewState["LastLoaded"] as string; } set { ViewState["LastLoaded"] = value; } } private void LoadUserControl() { string controlPath = LastLoadedControl; if (!string.IsNullOrEmpty(controlPath)) { UpdatePanel2.ContentTemplateContainer.Controls.Cle ar(); UserControl uc = (UserControl)LoadControl(controlPath); UpdatePanel2.ContentTemplateContainer.Controls.Add (uc); } } User Control Source: --------------------------------- <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUIClientSummary.ascx.cs" Inherits="WebApplication1.WebUIClientSummary" %> <p> Client Summary</p> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> User Control Code: ------------------------------- namespace WebApplication1 { public partial class WebUIClientSummary : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { TextBox1.Text = DateTime.Now.ToString(); } } } |
|
|
| Similar Threads | |
| document.getElementById(), error in content page content page Could someone explain: I have a java popup window function that I would like to pass a querystring ID from a hiddenfield on my asp.net content page. The following code... |
|
| Switch content if low bandwidth Is there a way where I can "guess" what relative speed the user's connection is? Currently, the client is wanting some graphical intensive content and I'd like to be able to... |
|
| error: Only Content controls are allowed directly in a content page that contains Content controls. putting a custom control in an aspx page that inherits from a master page is not working out for me. Any tips after getting that error? Also Element 'Search' is not a known... |
|
| Switch Content Hi Stefan, I have two postings which make use of two different templates. Can I switch their templates without creating new postings all over again. Thanks in... |
|
|
All times are GMT. The time now is 07:01 AM. | Privacy Policy
|