I am using WebMenu as a contextmenu for ultrawebgrid cells. The contextmenu works fine if I place the webgrid and webmenu directly in the page. The problem starts when I am trying to create a usercontrol using webgrid and webmenu, contextmenuclick(right click on grid cell) gives me an error saying "Popup name not valid".
igmenu_showMenu("<%=this.MROContextMenu.ClientID %>",null,0,0);
Thanks
I would actually recommend that rather than coding up the event handler explicitly as was done in the sample, you can use ASP.NET AJAX extensions to add the handler. The eventargs that you will get for your handler will take care of abstracting away differences, and you can use screenX and screenY to position your menu. http://asp.net/AJAX/Documentation/Live/ClientReference/Sys.UI/DomEventClass/SysUIDomEventAddHandlerMethod.aspx
hth,
-Tony
Thanks for your time and suggestions. I have gone through the Excel Copy paste sample before and infact that sample is the base for my grid.
I had a work around for my problem of contextmenu. I was struggling to create a usercontrol consisting webgrid and webmenu and it didnot work because of problem with MenuID. So I seperated them out. I have put the webgrid in the usercontrol and webmenu in the aspx page and ran the same scripts and it worked.
Now the only issue which remains is what you have mentioned "positioning the contextmenu". If I pass 0,0 as x,y then the menu is showing fine for some inner column cells but going out of screen for cells which are in the last column. Can I have the codebit of what you are talking abt passing event object, calculating the position so that it will work for firefox also?
Take a look at the Excel Copy & Paste sample in the samples browser. I spent a good day banging my head against the wall trying to figure out how to get a context menu positioned correctly cross browser, so I definitely feel your pain. As much as I understand why firefox doesn't have a global "event" object, it sure makes things hard :) The key is to pass the "event" parameter into the function as a parmeter. Firefox will always use the first parameter in an event handler as the event object.
Then you can calculate the position using the event object. A warning though - calculating positions cross browser is another headache. Lastly, you want to be sure to call igmenu_showMenu as you're doing above (menuid, null, x,y). I remember running into an issue with quotations not being correctly placed around my ID under some odd configuration, so you'll want to do a quick views source on your HTML page to be sure that <%= ...%> is actually rendering out what you think it should.
Its rendering the menuid as "MROGridControlMROContextMenu" i.e., parentcontrolid+contextmenuid.
I have avoided the event parameter as I have read that event is understood only by IE not other browsers and I am targeting IE and Firefox browsers.
To be sure if event param is causing the problem, I have tested the code passing the event parameter but it still didnot work. Not sure why !!
Thanks for the follow-up. Is the alert showing the correct client-side ID?
In any case, I believe the key here could be the parameters to the igmenu_showMenu method. I've found out several test project demonstrating this live in action, and they always required a valid "event" (the second parameter), plus some coordinates - x,y (third and fourth parameters).
You can find the following KB article useful:
HOWTO:How to show and hide the UltraWebMenu when used as a context menu
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=10083
It demonstrates sample code/approach, plus there a couple of projects attached to it where you can see this live in action.