protected void dlShortcuts_ItemDataBound(object sender, DataListItemEventArgs e) { try { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Wink.Shortcut shortcut = ((Wink.Shortcut)e.Item.DataItem); TextBox tbPosition = (TextBox)e.Item.FindControl("tbPosition"); tbPosition.Text = shortcut.position > 1000 ? "" : (shortcut.position).ToString(); TextBox tbDisplayName = (TextBox)e.Item.FindControl("tbDisplayName"); tbDisplayName.Text = shortcut.displayName; //BIND INFO BUTTON var props = typeof(Wink.Shortcut).GetProperties(); var properties = new List <KeyValuePair <string, string> >(); foreach (var prop in props) { if (prop.Name != "json") { TextInfo textInfo = new CultureInfo("en-US", false).TextInfo; string propname = textInfo.ToTitleCase(prop.Name.Replace("_", " ")); var propvalue = prop.GetValue(shortcut, null); if (propvalue != null) { properties.Add(new KeyValuePair <string, string>(propname, propvalue.ToString())); } } } DataList dlProperties = (DataList)e.Item.FindControl("dlProperties"); if (dlProperties != null) { dlProperties.DataSource = properties; dlProperties.DataBind(); } } } catch (Exception ex) { throw; //EventLog.WriteEntry("WinkAtHome.Shortcuts.dlShortcuts_ItemDataBound", ex.Message, EventLogEntryType.Error); } }
protected void btnClose_Click(object sender, EventArgs e) { try { LinkButton ib = (LinkButton)sender; TextBox tbPosition = (TextBox)ib.NamingContainer.FindControl("tbPosition"); TextBox tbDisplayName = (TextBox)ib.NamingContainer.FindControl("tbDisplayName"); Label lblPositionBad = (Label)ib.NamingContainer.FindControl("lblPositionBad"); ModalPopupExtender mpeInfo = (ModalPopupExtender)ib.NamingContainer.FindControl("mpeInfo"); Wink.Shortcut item = Wink.Shortcut.getShortcutByID(ib.CommandArgument); bool savePosSuccess = false; bool saveNameSuccess = false; if (item != null) { //SAVE POSITION try { Int32 pos = 9999; if (string.IsNullOrWhiteSpace(tbPosition.Text)) { savePosSuccess = true; } else if (Int32.TryParse(tbPosition.Text, out pos) && pos > 0 && pos < 1001) { List <string> existingList = new List <string>(); foreach (DataListItem dli in dlShortcuts.Items) { HiddenField hfShortcutID = (HiddenField)dli.FindControl("hfShortcutID"); existingList.Add(hfShortcutID.Value); } string newItem = item.id; existingList.RemoveAll(s => s == newItem); existingList.Insert(pos - 1, newItem); foreach (string ID in existingList) { int position = existingList.IndexOf(ID) + 1; Wink.Shortcut.setShortcutPosition(ID, position); } lblPositionBad.Visible = false; savePosSuccess = true; } else { lblPositionBad.Visible = true; } } catch (Exception ex) { lblPositionBad.Visible = true; } //SAVE DISPLAY NAME try { Wink.Shortcut.setShortcutDisplayName(item.id, tbDisplayName.Text); saveNameSuccess = true; } catch (Exception ex) { } } if (saveNameSuccess && savePosSuccess) { Session["modalshowing"] = "false"; mpeInfo.Hide(); BindData(); } else { mpeInfo.Show(); } } catch (Exception ex) { throw; //EventLog.WriteEntry("WinkAtHome.Shortcuts.btnClose_Click", ex.Message, EventLogEntryType.Error); } }