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

Wednesday, March 28, 2012

Updating a ContentPlaceHolder with Ajax

I am working on a project which uses a MasterPage with one ContentPlaceHolder. I have a custom menu control on the MasterPage. When an item in the menu is clicked I need the ContentPlaceHolder to be updated with the requested content. I know this can easily be done using an iframe, but I'd rather stay away from iframes and like to do this with Ajax.

Basically my question is if this is possible at all. I've been trying a couple of things but without success and I think it may have to do by the way a MasterPage works.
If not possible, is there some kind of workaround for this? (without residing to iframes)

Thanks!

Hi Rino,

I tried also the same thing as you. I had a menu on my master page and an ContentPlaceHolder in my update panel. That didn't work. I think it isn't possible what you want to do.

Regards,


Unfortunately, no. It's just not how master pages and AJAX work. I just finished a post on the topic here:http://odetocode.com/Blogs/scott/archive/2007/01/03/9682.aspx


Thanks guys for clearing this up!
Would be great as a new .Net feature though :)


You can do it right now, actually, it's not that big of a deal. You don't really need a contentplaceholder for it, just a Div that you can hook into w/ javascript (giving it an ID, for example). You have your menu item click handler fire a javascript function that calls a web service and then have the onrequest complete handler fill the div with the stuff it gets back.

paul.vencill:

You don't really need a contentplaceholder for it, just a Div that you can hook into w/ javascript (giving it an ID, for example). You have your menu item click handler fire a javascript function that calls a web service and then have the onrequest complete handler fill the div with the stuff it gets back.

Paul: Yes, but this is an entirely different approach.


Understood. I was trying to offer something that might work for his application. is there a good reason you can think of to limit his app to using contentplaceholders?

No, my goal was just to point out that updating content place holders with content from a different page isn't how the technologies work together. It seems to be a common question these days, so I'm trying to clear that up.

The right way to achieve this would be to use a solution like you proposed!


ah, ok, cool. :D

It is very easy.

See my last post about "Handling events...".

Saturday, March 24, 2012

upgraded to new March ctp, having 2 menu creates js error?

Hi I just upgraded to march ctp...

1. Are there any scripts? I saw in another topic post talk about copying the new scripts, but I thought its all in the dll now, http module to provide the javascript right? there are no .js files right?

2. I have 2 menus.. i am getting this error often (not always) upon moving my mouse off the menu/tab:

A Runtime Error has occurred.
Do you wish to Debug?

Line 220
Error: '0.cells' is null or not an object

I think it has something to do with the "Menu_Unhover" function for the menus, but I am not sure

First menu is in masterpage, second menu is tabbed and on a page that uses the ScriptManager and UpdatePanel

bump - this has been mentioned a few times.

It generates that error with a menu in a updatepanel.

If anyone knows how to fix the javascript to prevent this error as a workaround let me know.


I have not thoroughly tested, but I did this:

protected void Page_Load(object sender, EventArgs e)
{
//ScriptManager1.RegisterAsyncPostBackControl(ResumeWizardTabbedMenu);
ScriptManager1.RegisterControl(ResumeWizardTabbedMenu);
}

The idea came from this post:

http://forums.asp.net/1223652/ShowPost.aspx
ScriptManager1.RegisterAsyncPostbackControl(Menu1);

-chau


Hi everyone,

The Menu hover issue will be fixed in the April CTP of Atlas (soon to be released!).

Thanks,

Eilon

Wednesday, March 21, 2012

Use a menu control in updatepanel

that occurs a javascript error when click another tab: "0.cells" is null or not an object.

who can help me? thanks.

The menu control is not compatible with partial-page updates and can't be used inside a UpdatePanel.


what can i do if i want to implement this function?thx.
Could you run this in JS debugger and post a snippet of affected JS.. I vaguely remember dealing with this issue and it might allow us to see what is exactly happening

did quick google

and found e.g. this

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


thanks for your information, i read a blog and using this method it works well.

http://mcosier.blogspot.com/2006/12/0cells-is-null-or-not-object-aspnet-20.html

but i have a problem that:

it seems that using AsyncPostBackTrigger can't change the StaticSelectedStyle after i clicked another menuitem?

thanks.


I've 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. 

This one works great for me.

Thank you very very much.Big Smile

Great


it is working.. Smile Thank you for your great solutions.

thanks t0yBig Smile

i tryed it.and i dident give that error.

thanks again.


Dear sir

can you please tell me where to put this code in what event, name of the function it is very imp.

thank you,

please advise what to do.


This piece of Javascript has saved me hours of googling! Awesome work buddy and thanks heaps!

See for more info , which controls are not compatable with UpdatePanel

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


I cannot figure out how to use this fix. I put this script in my page and I'm still getting the 0.cells is nothing error.

How do I hook this up?

Thanks!


Have you tried the solution thatt0y provided..

It's working..Smile