Showing posts with label menu. Show all posts
Showing posts with label menu. Show all posts

Monday, March 26, 2012

prevent refresh between screens

Hi,

I want to prevent refresh between screens.I have menu in the top of screen and when I pass between screens I want that this menu be static and don't refresh.

How can I do it?

Hi Rayak,

If you want the menu on the top to don't refresh when you are opening another webpage it isn't possible. Openening a new page can't stop your menu from flickering. If you want to stop it from refresing when events happen on your page you can use an updatepanel. Put you menu in the updatepanel and asign trigger (controls) to the updatepanel. Hope this helps!

Regards,


I use Master Page .All menu is in Master Page.If I put updatepanel in Master Page ,it doesn't work.

Hi RayaK,

When you are using masterpages and you put your menu in the masterpage this will make it available to al the content pages that deriv e from that master page, but al the content pages are still different aspx pages. When you make a request to defaultB.aspx when you are at defaultA.aspx you are requesting a total new page which means that the menu will be rendered again but on another page (flickering). UpdatePanels are used when you want to update parts of a webpage. You stay at the same webpage but you need to update a part of a webpage. Hope this helps.

Regards,


Hi,

Ok,I understand.Maybe do you know another method how to do it?


Hi RayaK,

No i don't know a solution for this. i think that for now it isn't possbile so your menu will be flickering when you go to another page. SorryWink. Good luck with Ajax development

Regards,


Dennis van de Laar:

Hi RayaK,

No i don't know a solution for this. i think that for now it isn't possbile so your menu will be flickering when you go to another page. SorryWink. Good luck with Ajax development

Regards,

If you have a master page you can use that in the default.aspx. In the default page you can set an update panel arround the content zone with update method set to conditional and having the menu as a trigger. Now, inside the update panel all you need is a dynamic web user control loader that loads a control based on the user menu selection.

I'm pretty sure this architecture works, although I never tested it.

Also, note that approaching the problem in this way is not much different than loading the whole page again. When u wrap all this information in an update panel everything will travel back and forward on the wire...
Using custom AJAX callbacks is much more efficient.


HI DBA,

I disagree with you. The way you describe your solution isn't working. Some very simple test can made. I created 1 masterpage with an scriptmanager and an UpdatePanel. In the updatepanel is a contentplaceholder. I have 2 buttons on the masterpage. One is navigating to Page1 and one is navigating to Page2. Then i created 2 contentpage based on the masterpage. I put on both pages a label in the contentplaceholder which will be set with the name of the page. When i click on the buttons on the masterpage it will build the webpage from scratch, because its a new page.

One thing is true. when i also put a button in the contentplaceholder which will set the label.Text from NAME OF THE PAGE to the CURRENT DATE. This will be done by partial rendering. This is correct because you stay on the same page and you are in the updatepanel which is deployed on the masterpage

MasterPage:

<%

@.MasterLanguage="C#"AutoEventWireup="true"CodeFile="UpdatePanelMasterPage.master.cs"Inherits="Masterpage_UpdatePanelMasterPage" %>

<!

DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

htmlxmlns="http://www.w3.org/1999/xhtml">

<

headrunat="server"><title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager><asp:ButtonID="Button1"runat="server"OnClick="Button1_Click"Text="Page1"/><asp:ButtonID="Button2"runat="server"OnClick="Button2_Click"Text="Page2"/><div><asp:UpdatePanelID="UpdatePanel1"runat="server"><ContentTemplate><asp:contentplaceholderid="ContentPlaceHolder1"runat="server"></asp:contentplaceholder></ContentTemplate></asp:UpdatePanel></div></form>

</

body>

</

html>

ContentPage1:

<%

@.PageLanguage="C#"MasterPageFile="~/Masterpage/UpdatePanelMasterPage.master"AutoEventWireup="true"CodeFile="UpdatePanelMaster.aspx.cs"Inherits="UpdatePanelMaster"Title="Untitled Page" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:Buttonid="Button1"runat="server"OnClick="Button1_Click"Text="Button"/><br/><asp:Labelid="Label1"runat="server"Text="Label"></asp:Label>

</

asp:Content>

Code behind:

using

System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

public

partialclassUpdatePanelMaster : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

this.Label1.Text ="Page1";

}

protectedvoid Button1_Click(object sender,EventArgs e)

{

this.Label1.Text =DateTime.Now.ToString();

}

}

ContentPage2:

<%

@.PageLanguage="C#"MasterPageFile="~/Masterpage/UpdatePanelMasterPage.master"AutoEventWireup="true"CodeFile="UpdatePanelMaster2.aspx.cs"Inherits="UpdatePanelMaster2"Title="Untitled Page" %>

<

asp:ContentID="Content1"ContentPlaceHolderID="ContentPlaceHolder1"Runat="Server"><asp:Labelid="Label1"runat="server"Text="Label"></asp:Label>

</

asp:Content>

Code behind:

using

System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

public

partialclassUpdatePanelMaster2 : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

this.Label1.Text ="Page2";

}

}

Regards,


Dennis van de Laar:

HI DBA,

I disagree with you. The way you describe your solution isn't working. Some very simple test can made. I created 1 masterpage with an scriptmanager and an UpdatePanel. In the updatepanel is a contentplaceholder. I have 2 buttons on the masterpage. One is navigating to Page1 and one is navigating to Page2. Then i created 2 contentpage based on the masterpage. I put on both pages a label in the contentplaceholder which will be set with the name of the page. When i click on the buttons on the masterpage it will build the webpage from scratch, because its a new page.

One thing is true. when i also put a button in the contentplaceholder which will set the label.Text from NAME OF THE PAGE to the CURRENT DATE. This will be done by partial rendering. This is correct because you stay on the same page and you are in the updatepanel which is deployed on the masterpage

HelloDennis van de Laar,

That wasn't at all what I suggested:

I suggested you to try the following structure:

[MasterPage]
<asp:ScriptManagerID="ScriptManager"runat="server" />
<asp:contentplaceholderid="cphMainContent"runat="server">
</asp:contentplaceholder>

[Default.aspx]

<%@.PageLanguage="C#"MasterPageFile="~/MasterPages/Default.master"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="MasterPages_Default"Title="The dynamic saga" %>

<asp:ContentID="MainContent"ContentPlaceHolderID="cphMainContent"Runat="Server">
<asp:Buttonrunat="server"ID="btnLoadPage1" text="Load page 1"OnClick="btnLoadPage1_Click" />
<asp:UpdatePanelID="UpdPnlMainContent"runat="server">
<Triggers>
<!-- Insert Menu trigger here -->
</Triggers>
<ContentTemplate>
<asp:PlaceHolderrunat="server"ID="phMainContent" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content
[Default.aspx.cs]
protected void btnLoadPage1_Click(object sender, EventArgs e)
{
Control ctrlDynamicPage = LoadControl("~/WebUserControls/Page1.acx");
phMainContent.Controls.Add(ctrlDynamicPage);
}

Again, I haven't tested this code but this was what I had in mind. In order to add more pages you just need to create them in web user controls and then make sure you have a DB or something with the virtual path the loader needs to fetch.

Best regards,
DBA


Hi DBA,

I see what you suggest. I don't know if this is the solution for Rayak. The solution you suggest stays on the same page and reloads it with usercontrols. This can be a solution. if its possible to create a trigger from a control of the masterpage.

Regards,


Dennis van de Laar:

Hi DBA,

I see what you suggest. I don't know if this is the solution for Rayak. The solution you suggest stays on the same page and reloads it with usercontrols. This can be a solution. if its possible to create a trigger from a control of the masterpage.

Regards,

You don't have to do that. You just need to have something like this in your web user control:

<asp:Button runat="server" ID="btnMyAction" OnClick="DoSomething" /><asp:UpdatePanel UpdateMode="Conditional"><Triggers><asp:AsyncPostBackTrigger ControlId="btnMyAction" EventName="Click" /></Triggers><ContentTemplate><asp:Label runat="server" ID="lblTest" Text="not updated" /></ContentTemplate></asp:UpdatePanel>
In the code behind of the web user control:
protected void DoSomething(object sender, EventArgs e){ lblTest.Text ="updated by ajax callback";}
With this you are encapsulating the update panels, which again is not the optimal solution if you are considering resources. But, the bottom line is that it should work and solve the presented problem.
Best regards.


If RayaK just wants to prevent the static content flickering when navigating between screens:

- if your content is really "static" (the position, height etc. are the same for each page) you won't get flicker on firefox (not 100%, sometimes even firefox flickers)

- ie6 and (saddly) ie7 usually will flicker, but you can eliminate this flicker with the following in the codebehind (put it in the oninit or onload). (Firefox simply ignores this.)

HtmlMeta meta = new HtmlMeta( );
meta.Attributes.Add( "http-equiv", "Page-Enter" );
meta.Attributes.Add( "content", "progid:DXImageTransform.Microsoft.Fade(duration=0)" );
this.Header.Controls.AddAt( 0, meta );

This trick and forms are well "documented" all over the web.

Probblem with Menu control inside an update panel

Hi,

I have a master page with a script manager ,update panel and Content Palce Holder. in the default page which uses the masterpage I have added a menu control, textbox and a button. I have two problems which I have seen in the past in other versions of ajax. I have not coded anything other than just these controls on a page

1) I could click on button all day long and there is no java script error but as soon as I click on a menu item I get javascript error saying:

Line:221

Char:20

Error '0.cells' is null or not an object

code: 0

2) I can not get my CSS sheet work in my app theme for the background images. I have the following code in my CSS

.Menu1BackGround

{

background-image:url(/Images/Menu1_Background.bmp);

}

and I have assigned the it to the menu. Nothing happens as if it does not recognize the image path. I could add the background:black to the code and it works fine for the color but not the image. I am not sure if thisis because of the same problem.

Any body have any ideas?

Thanks

Seehttp://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx#UpdatePanelCompatibleControls. The Menu control is not supported inside an UpdatePanel.

I have been using this piece of javascript to go around the menu problem:

var oldMenu_HideItems = Menu_HideItems;if(oldMenu_HideItems){Menu_HideItems = function(items){if (!items || ((typeof(items.tagName) =="undefined") && (items instanceof Event))) { items = __rootMenuItem; }if(items && items.rows && items.rows.length == 0){ items.insertRow(0); }return oldMenu_HideItems(items);} }
I got it from the asp:menu javascript code and I hook it to "patch" the problem.
Adding it to a page where a menu resides makes the javascript error go away. 

http://forums.asp.net/thread/1517884.aspx

HTH


Menu control is not compatable with AJAX.

I m also facing sme problem..

Wednesday, March 21, 2012

problem in Update panel

Hi

I am using masterpage in my application.I put two contentplaceholder..left side and right side...In left side content I am putting menu...whenever i click on left menu, page should be open in right side contentplaceholder.Whole page should not be refresh....just right side contentplace holder should be change according to left menu click..it is possible using update panel ?..i put updatepanel on right side but it is not working..

Can anybody help..Please....

Please help me...

Thanks a lot...

Hi Sejal,

Check this article on using update panel in master pages -

http://ajax.asp.net/docs/tutorials/UsingUpdatePanelMasterPages.aspx

You can also try using update panel triggers(not sure how it will work in master page) -

http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx#SpecifyingUpdatePaneltriggers