Calendar demo
Source of:
ContextMenu.aspx
<script runat="server">
static string ToString(object v) {
if (v==null) return "NULL";
return HttpUtility.HtmlEncode(v.ToString());
}
protected void BodyMenu_Command(object sender, ActionEventArgs e) {
InfoLabel.Text = "Body menu clicked<br>Date-time: <b>"+Sch.ClickedDateTime+
"</b><br>Row: <b>"+ToString(Sch.ClickedRow)+"</b>";
}
protected void TimeLineMenu_Command(object sender, ActionEventArgs e) {
InfoLabel.Text = "Time line clicked<br>Date-time: <b>"+Sch.ClickedDateTime+"</b>";
}
protected void ResourceHeaderMenu_Command(object sender, ActionEventArgs e) {
InfoLabel.Text = "Resource header clicked<br>Column: <b>"+ToString(Sch.ClickedColumn)+"</b>";
}
protected void ResourceListMenu_Command(object sender, ActionEventArgs e) {
InfoLabel.Text = "Resource list clicked<br>Column: <b>"+ToString(Sch.ClickedColumn)+
"</b><br>Row: <b>"+ToString(Sch.ClickedRow)+"</br>";
}
protected void CaptionMenu_Command(object sender, ActionEventArgs e) {
InfoLabel.Text = "Caption clicked";
}
protected void DefaultItemMenu_Command(object sender, ActionEventArgs e) {
switch (e.Name) {
case "setbackground":
if (Sch.ClickedItem!=null)
Sch.ClickedItem.Style.BackImageUrl = "~/images/background.gif";
break;
case "info":
InfoLabel.Text = "Scheduler item clicked<br>Item: <b>"+ToString(Sch.ClickedItem)+"</b>";
break;
}
}
</script>
<table width="100%">
<tr>
<td>
<gos:Scheduler ID="Sch" runat="server" Height="252px" Width="556px" BackColor="Lavender"
Caption="Scheduler linked menus" Font-Names="Verdana" Font-Size="Small" FreeDateColor="LightCoral"
FreeTimeColor="LightSteelBlue" HorizontalHeaderLine="1px Black Solid" HorizontalLine="1px SlateBlue Solid"
VerticalLine0="2px SlateBlue Solid" VerticalLine1="1px SlateBlue Solid" VerticalResourceLine="1px SlateBlue Solid"
ForeColor="Navy" SplitterColor="0, 0, 192" VerticalLine2="1px LightSteelBlue Dotted"
ObjectID="SchObj" LinkLine="1px RoyalBlue Solid" BehaviorOptions="AllowOverlapItems, Default">
<Columns>
<gos:ResourceColumn Text="Caption">
</gos:ResourceColumn>
</Columns>
<BodyStyle BackColor="Lavender" ContextMenuID="BodyMenu">
</BodyStyle>
<TimeLineStyle Font-Size="X-Small" ResourceImage="Blue" ContextMenuID="TimeLineMenu">
</TimeLineStyle>
<CaptionStyle HorizontalAlign="Center" ResourceImage="Blue" BorderColor="Navy" BorderStyle="Solid"
BorderWidth="1px" Font-Bold="True" Font-Size="X-Small" ContextMenuID="CaptionMenu">
</CaptionStyle>
<ResourceListStyle BackColor="AliceBlue" ContextMenuID="ResourceListMenu">
</ResourceListStyle>
<ResourceHeaderStyle BackColor="AliceBlue" ContextMenuID="ResourceHeaderMenu">
</ResourceHeaderStyle>
<DefaultItemStyle ContextMenuID="DefaultItemMenu">
</DefaultItemStyle>
</gos:Scheduler>
</td>
<td valign="top">
An example shows how to link a context menu to a scheduler.
<br />
Right-click on a resource, hours, date or an items rectangle.<br />
<br />
You can use client side <em>ContextMenu.OnClientMenuActivate</em> event to initialize
menu items before showing menu in the browser. Notice that one context menu is differentfor
different items.<br />
<br />
<asp:Label ID="InfoLabel" runat="server" ForeColor="Green"></asp:Label>
</tr>
</table>
<span style="font-size: 8pt">A <em>Scheduler.Web</em> library contains objects allowing
you to define context menus. These are menus displayed after right clicking appropriate
area and performing some actions on it.<br />
A scheduler control has many areas, context menus can be assigned to. A way these
pages are displayed and area-related events are defined by <em>Sch.XxxxStyle</em>
properties corresponding to these areas. For example a <em>BodyStyle</em> corresponds
to main scheduler grid, <em>DefaultItemStyle</em> corresponds to <em>SchedulerItem</em>
objects displayed on it, and <em>ResourceListStyle</em> to a list (tree) of resources
in a left part of a control.
<br />
Objects returned by these properties have among others a <em>ContextMenuID</em>
property containing an identifier of a context menu displayed after right clicking
an area. For example a <em>Sch.CaptionStyle.ContextMenuID</em> is a menu displayed
on a scheduler title rectangle in an upper part of a control.<br />
Assigning a context menu is done by creating a <em>ContextMenu</em> object and assigning
its identifier to appropriate <em>XxxxStyle.ContextMenuID</em> property.<br />
After a function from a menu is selected, a server event, client <strong>JavaScript</strong>
or a <strong>HTML</strong> page can be called. This can be set using <em>ContextMenu</em>
object properties, but it is always necessary to determine an area of a scheduler
control a menu was opened for. Ex. for which <em>SchedulerItem</em> object a menu
determined by a <em>Sch.DefautlItemStyle.ContextMenuID</em> property was opened.
This can be done using <em>ClickedItem</em>, <em>ClickedRow</em>, <em>ClickedColumn</em>
and <em>ClickedDateTime</em> properties locating a place right clicked.<br />
After selecting a "Get Information" function from a menu on this sample page an
appropriate server event assigned to a context menu is called. In this event an
event that was called is precisely described along with corresponding <em>ClickedXXX</em>
parameters. For example if a menu was opened for a <em>ResourceList</em> (a list
or a tree in a left part of a control), information on <em>ClickedRow</em> and <em>ClickedColumn</em>
is added to information on event type.</span><br />
<go:ContextMenuBox ID="BodyMenu" runat="server" Font-Names="Tahoma" Font-Size="8pt"
OnCommand="BodyMenu_Command">
<Items>
<go:MenuActionItem Text="Body rectangle" Enabled="False">
</go:MenuActionItem>
<go:MenuSeparatorItem />
<go:MenuActionItem Text="Get information" CommandName="info">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 2">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 3">
</go:MenuActionItem>
</Items>
<EventCommand UseCallback="False" />
</go:ContextMenuBox>
<go:ContextMenuBox ID="TimeLineMenu" runat="server" Font-Names="Tahoma" Font-Size="8pt"
OnCommand="TimeLineMenu_Command">
<Items>
<go:MenuActionItem Text="Time line" Enabled="False">
</go:MenuActionItem>
<go:MenuSeparatorItem />
<go:MenuActionItem Text="Get information" CommandName="info">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 2">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 3">
</go:MenuActionItem>
</Items>
<EventCommand UseCallback="False" />
</go:ContextMenuBox>
<go:ContextMenuBox ID="ResourceHeaderMenu" runat="server" Font-Names="Tahoma" Font-Size="8pt"
OnCommand="ResourceHeaderMenu_Command">
<Items>
<go:MenuActionItem Text="Resource header" Enabled="False">
</go:MenuActionItem>
<go:MenuSeparatorItem />
<go:MenuActionItem Text="Get information" CommandName="info">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 2">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 3">
</go:MenuActionItem>
</Items>
<EventCommand UseCallback="False" />
</go:ContextMenuBox>
<go:ContextMenuBox ID="ResourceListMenu" runat="server" Font-Names="Tahoma" Font-Size="8pt"
OnCommand="ResourceListMenu_Command">
<Items>
<go:MenuActionItem Text="Resource list" Enabled="False">
</go:MenuActionItem>
<go:MenuSeparatorItem />
<go:MenuActionItem Text="Get information" CommandName="info">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 2">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 3">
</go:MenuActionItem>
</Items>
<EventCommand UseCallback="False" />
</go:ContextMenuBox>
<go:ContextMenuBox ID="CaptionMenu" runat="server" Font-Names="Tahoma" Font-Size="8pt"
OnCommand="CaptionMenu_Command">
<Items>
<go:MenuActionItem Text="Caption rectangle" Enabled="False">
</go:MenuActionItem>
<go:MenuSeparatorItem />
<go:MenuActionItem Text="Get information" CommandName="info">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 2">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 3">
</go:MenuActionItem>
</Items>
<EventCommand UseCallback="False" />
</go:ContextMenuBox>
<go:ContextMenuBox ID="DefaultItemMenu" runat="server" Font-Names="Tahoma" Font-Size="8pt"
OnCommand="DefaultItemMenu_Command" ObjectID="DefaultItemMenuObj">
<Items>
<go:MenuActionItem Text="Scheduler item" Enabled="False">
</go:MenuActionItem>
<go:MenuSeparatorItem />
<go:MenuActionItem Text="Get information" CommandName="info">
</go:MenuActionItem>
<go:MenuActionItem Text="Set background" CommandName="setbackground">
</go:MenuActionItem>
<go:MenuActionItem Text="Menu item 3">
</go:MenuActionItem>
</Items>
<EventCommand UseCallback="False" />
</go:ContextMenuBox>