User Control Page /MobileModules/Events.ascx (C#)
1: <%@ Control Language="C#" Inherits="ASPNetPortal.MobilePortalModuleControl" %>
2: <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
3: <%@ Register TagPrefix="portal" TagName="Title" Src="~/MobileModuleTitle.ascx" %>
4: <%@ Register TagPrefix="portal" Namespace="ASPNetPortal.MobileControls" Assembly="Portal" %>
5: <%@ Import Namespace="System.Data" %>
6:
7: <%--
8:
9: The Events Mobile User Control renders event modules in the portal.
10:
11: The control consists of two pieces: a summary panel that is rendered when
12: portal view shows a summarized view of all modules, and a multi-part panel
13: that renders the module details.
14:
15: --%>
16:
17: <script runat="server">
18:
19: DataSet ds = null;
20: int currentIndex = 0;
21:
22: //*********************************************************************
23: //
24: // Page_Load Event Handler
25: //
26: // The Page_Load event handler on this User Control is used to
27: // obtain a DataSet of announcement information from the Events
28: // table, and then databind the results to the module contents.
29: //
30: //*******************************************************
31:
32: void Page_Load(Object sender, EventArgs e) {
33:
34: // Obtain announcement information from Events table
35: ASPNetPortal.EventsDB ev = new ASPNetPortal.EventsDB();
36: ds = ev.GetEvents(ModuleId);
37:
38: // DataBind User Control
39: DataBind();
40: }
41:
42:
43: //*********************************************************************
44: //
45: // SummaryView_OnItemCommand Event Handler
46: //
47: // The SummaryView_OnItemCommand event handler is called when the user
48: // clicks on a "More" link in the summary view. It calls the
49: // ShowEventDetails utility method to show details of the event.
50: //
51: //*********************************************************************
52:
53: void SummaryView_OnItemCommand(Object sender, RepeaterCommandEventArgs e) {
54: ShowEventDetails(e.Item.ItemIndex);
55: }
56:
57: //*********************************************************************
58: //
59: // EventsList_OnItemCommand Event Handler
60: //
61: // The EventsList_OnItemCommand event handler is called when the user
62: // clicks on an item in the list of events. It calls the
63: // ShowEventDetails utility method to show details of the event.
64: //
65: //*********************************************************************
66:
67: void EventsList_OnItemCommand(Object sender, ListCommandEventArgs e) {
68: ShowEventDetails(e.ListItem.Index);
69: }
70:
71: //*********************************************************************
72: //
73: // DetailsView_OnClick Event Handler
74: //
75: // The DetailsView_OnClick event handler is called when the user
76: // clicks in the details view to return to the summary view.
77: //
78: //*********************************************************************
79:
80: void DetailsView_OnClick(Object sender, EventArgs e) {
81:
82: // Make the parent tab show module summaries again.
83: Tab.SummaryView = true;
84: }
85:
86: //*********************************************************************
87: //
88: // ShowEventDetails Method
89: //
90: // The ShowEventDetails method sets the active pane of
91: // the module to the details view, and shows the details of the
92: // given item.
93: //
94: //*********************************************************************
95:
96: void ShowEventDetails(int itemIndex) {
97:
98: currentIndex = itemIndex;
99:
100: // Switch the visible pane of the multi-panel view to show
101: // event details.
102: MainView.ActivePane = EventDetails;
103:
104: // rebind the details panel
105: EventDetails.DataBind();
106:
107: // Make the parent tab switch to details mode, showing this module.
108: Tab.ShowDetails(this);
109: }
110:
111: //*********************************************************************
112: //
113: // FormatChildField Method
114: //
115: // The FormatChildField method returns the selected field as a string,
116: // if the row is not empty. If empty, it returns String.Empty.
117: //
118: //*********************************************************************
119:
120: string FormatChildField (string fieldName) {
121:
122: if (ds.Tables[0].Rows.Count > 0)
123: return ds.Tables[0].Rows[currentIndex][fieldName].ToString();
124: else
125: return String.Empty;
126: }
127:
128:
129: </script>
130:
131: <mobile:Panel runat="server" id="summary">
132: <DeviceSpecific>
133: <Choice Filter="isJScript">
134:
135: <ContentTemplate>
136: <portal:Title runat="server" />
137: <font face="Verdana" size="-2">
138: <asp:Repeater runat="server" DataSource="<%# ds %>" OnItemCommand="SummaryView_OnItemCommand">
139: <ItemTemplate>
140: <b><%# DataBinder.Eval(Container.DataItem, "Title") %></b><br>
141: <i><%# DataBinder.Eval(Container.DataItem, "WhereWhen") %></i>
142: <asp:LinkButton runat="server" Text="more" /><br><br>
143: </ItemTemplate>
144: </asp:Repeater>
145: </font><br>
146: </ContentTemplate>
147:
148: </Choice>
149: </DeviceSpecific>
150: </mobile:Panel>
151:
152: <portal:MultiPanel runat="server" id="MainView" Font-Name="Verdana" Font-Size="Small">
153:
154: <portal:ChildPanel id="EventsList" runat="server">
155: <portal:Title runat="server" />
156: <mobile:List runat="server" OnItemCommand="EventsList_OnItemCommand" DataTextField="Title" DataSource="<%# ds %>" />
157: </portal:ChildPanel>
158:
159: <portal:ChildPanel id="EventDetails" runat="server">
160: <portal:Title runat="server" Text='<%# FormatChildField("Title") %>' />
161: <mobile:Label runat="server" Font-Italic="true" Text='<%# FormatChildField("WhereWhen") %>' />
162: <br>
163: <mobile:TextView runat="server" Text='<%# FormatChildField("Description") %>' />
164: <portal:LinkCommand runat="server" OnClick="DetailsView_OnClick" Text="back" />
165: </portal:ChildPanel>
166:
167: </portal:MultiPanel>
168: