Hello,
I need a solution to completly rebind the items of the context menu on runtime at server side when user right-clicks.
Items are currently bound with following code. Now I like to bind the items not in page_load, but when user right-clicks, because items are generated in future in a separate business logic on another server and they can change between page_loads.
I have tried a server callback event on client event "OnClientShowing"; it works but unfortunately no changes can be done here. The context menu will not change.
Does anybody find a solution for that?
Thanks in advance
René
I need a solution to completly rebind the items of the context menu on runtime at server side when user right-clicks.
Items are currently bound with following code. Now I like to bind the items not in page_load, but when user right-clicks, because items are generated in future in a separate business logic on another server and they can change between page_loads.
I have tried a server callback event on client event "OnClientShowing"; it works but unfortunately no changes can be done here. The context menu will not change.
Does anybody find a solution for that?
Thanks in advance
René
<
telerik:RadContextMenu
ID
=
"RadContextMenu1"
runat
=
"server"
>
<
Targets
>
<
telerik:ContextMenuControlTarget
ControlID
=
"TextBox1"
/>
<
telerik:ContextMenuControlTarget
ControlID
=
"Label1"
/>
<
telerik:ContextMenuControlTarget
ControlID
=
"Image1"
/>
</
Targets
>
<
Items
>
</
Items
>
</
telerik:RadContextMenu
>
Private
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
If
Not
IsPostBack
Then
RadContextMenu1.DataTextField =
"Text"
RadContextMenu1.DataNavigateUrlField =
"Url"
RadContextMenu1.DataFieldID =
"ID"
RadContextMenu1.DataFieldParentID =
"ParentID"
RadContextMenu1.DataSource = GenerateSiteData()
RadContextMenu1.DataBind()
End
If
End
Sub
Private
Function
GenerateSiteData()
As
ArrayList
Dim
siteData
As
New
ArrayList()
siteData.Add(
New
SiteDataItem(1,
Nothing
,
"All Sites"
,
""
))
siteData.Add(
New
SiteDataItem(2, 1,
"Search Engines"
,
""
))
siteData.Add(
New
SiteDataItem(3, 1,
"News Sites"
,
""
))
siteData.Add(
New
SiteDataItem(4, 2,
"Yahoo"
,
"http://www.yahoo.com"
))
siteData.Add(
New
SiteDataItem(5, 2,
"MSN"
,
"http://www.msn.com"
))
siteData.Add(
New
SiteDataItem(6, 2,
"Google"
,
"http://www.google.com"
))
siteData.Add(
New
SiteDataItem(7, 3,
"CNN"
,
"http://www.cnn.com"
))
siteData.Add(
New
SiteDataItem(8, 3,
"BBC"
,
"http://www.bbc.co.uk"
))
siteData.Add(
New
SiteDataItem(9, 3,
"FOX"
,
"http://www.foxnews.com"
))
Return
siteData
End
Function
Public
Class
SiteDataItem
Private
_text
As
String
Private
_url
As
String
Private
_id
As
Integer
Private
_parentId
As
Integer
Public
Property
Text()
As
String
Get
Return
_text
End
Get
Set
(
ByVal
value
As
String
)
_text = value
End
Set
End
Property
Public
Property
Url()
As
String
Get
Return
_url
End
Get
Set
(
ByVal
value
As
String
)
_url = value
End
Set
End
Property
Public
Property
ID()
As
Integer
Get
Return
_id
End
Get
Set
(
ByVal
value
As
Integer
)
_id = value
End
Set
End
Property
Public
Property
ParentID()
As
Integer
Get
Return
_parentId
End
Get
Set
(
ByVal
value
As
Integer
)
_parentId = value
End
Set
End
Property
Public
Sub
New
(
ByVal
id
As
Integer
,
ByVal
parentId
As
Integer
,
ByVal
text
As
String
,
ByVal
url
As
String
)
_id = id
_parentId = parentId
_text = text
_url = url
End
Sub
End
Class