This project is read-only.

Error if contextmenu not set

Topics: User Forum
Oct 18, 2006 at 12:30 AM
Just started playing with it and its great, except that I'm not looking to use the contextmenus and I get errors if I don't include them. I took a quick check and if you make this simple change then contextmenu won't be required:

In xGrid.cs go down to

public string ContextMenuID

and replace

return contextMenu.ClientID;


if (contextMenu!=null)
return contextMenu.ClientID;
return null;
Oct 24, 2006 at 11:12 AM
So you mean, when you don't include the contextmenu on the page, you are getting an exception because my code is trying to find the control. It is not finding it, so it is sending an exception right?

Now, instead I can check if the control is found and accordingly I return values.

Thank you. I just updated it and I will upload it right now!

Nov 3, 2006 at 7:47 AM
I'm still getting this exception and the control won't render in the designer. I never used to have it at all, but in one particular project ( nothing fancy at all going on, just basic masterpage setup ) I'm getting it all the time.

I've tried with the new and old release.
Jun 18, 2007 at 3:54 PM
Edited Jun 18, 2007 at 4:06 PM
try this instead:

public string ContextMenuID
ContextMenu contextMenu=null;
string contextMenuID = this.ViewState["ContextMenuID"] as string;

if (!string.IsNullOrEmpty(contextMenuID))
contextMenu = Utility.FindControl(this.Parent, contextMenuID) as ContextMenu;

if (contextMenu != null)
return contextMenu.ClientID;

return null;