public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections) { if (ph == null) { return; } if (selections == null) { return; } OptionSelection val = selections.FindByOptionId(baseOption.Bvin); if (val == null) { return; } System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)ph.FindControl("opt" + baseOption.Bvin.Replace("-", "")); if (ddl != null) { if (ddl.Items.FindByValue(val.SelectionData) != null) { ddl.ClearSelection(); ddl.Items.FindByValue(val.SelectionData).Selected = true; } } }
public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph) { OptionSelection result = new OptionSelection(); result.OptionBvin = baseOption.Bvin; foreach (OptionItem o in baseOption.Items) { if (!o.IsLabel) { string radioId = "opt" + o.Bvin.Replace("-", ""); System.Web.UI.HtmlControls.HtmlInputRadioButton rb = (System.Web.UI.HtmlControls.HtmlInputRadioButton)ph.FindControl(radioId); if (rb != null) { if (rb.Checked) { result.SelectionData = o.Bvin; return(result); } } } } return(result); }
public static void ProductOptionsAsControls(Catalog.OptionList options, System.Web.UI.WebControls.PlaceHolder ph) { foreach (Catalog.Option opt in options) { if (!opt.NameIsHidden) { System.Web.UI.LiteralControl lit = new System.Web.UI.LiteralControl("<label for=\"" + opt.Bvin.Replace("-", "") + "\">" + opt.Name + "</label>"); lit.EnableViewState = false; ph.Controls.Add(lit); } System.Web.UI.LiteralControl lit2 = new System.Web.UI.LiteralControl("<span class=\"choice\">"); lit2.EnableViewState = false; ph.Controls.Add(lit2); opt.RenderAsControl(ph); System.Web.UI.LiteralControl lit3 = new System.Web.UI.LiteralControl("</span>"); lit3.EnableViewState = false; ph.Controls.Add(lit3); } }
/// <summary> /// Page extention method to register javascript /// </summary> /// <param name="objPage">The obj page.</param> /// <param name="JsPath">Javascript name with subfolder path</param> /// <param name="Index">index of css to add at</param> /// <remarks></remarks> public static void RegisterJavaScript(this System.Web.UI.Page objPage, string JsPath, int Index = 0) { string strVersion = getCSSJSVersion(); HtmlGenericControl gc1 = new HtmlGenericControl("script"); gc1.Attributes.Add("type", "text/javascript"); gc1.Attributes.Add("src", objPage.GetJScriptPath().ToLower() + JsPath.ToLower() + strVersion); System.Web.UI.WebControls.PlaceHolder ph = objPage.Master.FindControl("phJavaScripts") as System.Web.UI.WebControls.PlaceHolder; if (ph != null) { if (Index == 0) { ph.Controls.Add(gc1); } else { ph.Controls.AddAt(Index, gc1); } } else { if (Index == 0) { objPage.Header.Controls.Add(gc1); } else { objPage.Header.Controls.AddAt(Index, gc1); } } }
public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph) { OptionSelection result = new OptionSelection(); result.OptionBvin = baseOption.Bvin; string val = string.Empty; foreach (OptionItem o in baseOption.Items) { if (!o.IsLabel) { string checkId = "opt" + o.Bvin.Replace("-", ""); System.Web.UI.HtmlControls.HtmlInputCheckBox cb = (System.Web.UI.HtmlControls.HtmlInputCheckBox)ph.FindControl(checkId); if (cb != null) { if (cb.Checked) { string temp = ""; if (val.Length > 0) { temp += ","; } temp += o.Bvin; val += temp; } } } } result.SelectionData = val; return(result); }
public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections) { if (ph == null) { return; } if (selections == null) { return; } OptionSelection val = selections.FindByOptionId(baseOption.Bvin); if (val == null) { return; } string[] vals = val.SelectionData.Split(','); foreach (string s in vals) { string checkId = "opt" + s.Replace("-", ""); System.Web.UI.HtmlControls.HtmlInputCheckBox cb = (System.Web.UI.HtmlControls.HtmlInputCheckBox)ph.FindControl(checkId); if (cb != null) { cb.Checked = true; } } }
public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections) { if (ph == null) { return; } if (selections == null) { return; } OptionSelection val = selections.FindByOptionId(baseOption.Bvin); if (val == null) { return; } string radioId = "opt" + val.SelectionData.Replace("-", ""); System.Web.UI.HtmlControls.HtmlInputRadioButton rb = (System.Web.UI.HtmlControls.HtmlInputRadioButton)ph.FindControl(radioId); if (rb != null) { rb.Checked = true; } }
/// <summary> /// 注册一个处部CSS文件 /// </summary> /// <param name="placeHolder">PlaceHolder组件</param> /// <param name="cssFile">CSS文件</param> public static void LoadCss(System.Web.UI.WebControls.PlaceHolder placeHolder, string cssFile) { HtmlGenericControl objLink = new HtmlGenericControl("LINK"); objLink.Attributes["rel"] = "stylesheet"; objLink.Attributes["type"] = "text/css"; objLink.Attributes["href"] = cssFile; placeHolder.Controls.Add(objLink); //<asp:placeholder id="MyCSS" runat="server"></asp:placeholder> }
public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph) { OptionSelection result = new OptionSelection(); result.OptionBvin = baseOption.Bvin; System.Web.UI.WebControls.TextBox tb = (System.Web.UI.WebControls.TextBox)ph.FindControl("opt" + baseOption.Bvin.Replace("-", "")); if (tb != null) { result.SelectionData = tb.Text.Trim(); } return(result); }
public void RenderAndAttachCustomControl(ref System.Web.UI.WebControls.PlaceHolder ph, XmlDocument moduledoc, XmlDocument node) { System.Text.StringBuilder html = new System.Text.StringBuilder(); Framework.Utilities.ModulesProcessing mp = new ModulesProcessing(); foreach (XmlNode module in moduledoc) { this.Modules = mp.FetchModules(module); foreach (Module m in this.Modules) { ph.Controls.Add(mp.LoadControl(m.Path, this.MasterPage, node, m.ParamList, this.Namespaces)); } this.Modules = null; } }
/* * Page Events */ /// <summary> /// /// </summary> protected void Page_Load(System.Object sender, System.EventArgs args) { if (this.InboxDataGrid == null) { this.InboxDataGrid = (System.Web.UI.WebControls.DataGrid) this.SharpUI.FindControl("InboxDataGrid"); this.inboxWindowSearchHolder = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("inboxWindowSearchHolder"); System.String mode = Page.Request.QueryString["mode"]; if (mode != null && mode.Equals("trash")) { this.InboxDataGrid.Columns[5].Visible = false; } } this.SharpUI.nextPageImageButton.Click += new System.Web.UI.ImageClickEventHandler(nextPageButton_Click); this.SharpUI.prevPageImageButton.Click += new System.Web.UI.ImageClickEventHandler(prevPageButton_Click); this.SharpUI.refreshPageImageButton.Click += new System.Web.UI.ImageClickEventHandler(refreshPageButton_Click); }
public void RenderAsControl(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph) { foreach (OptionItem o in baseOption.Items) { if (!o.IsLabel) { System.Web.UI.HtmlControls.HtmlInputRadioButton rb = new System.Web.UI.HtmlControls.HtmlInputRadioButton(); rb.ClientIDMode = System.Web.UI.ClientIDMode.Static; rb.ID = "opt" + o.Bvin.Replace("-", ""); rb.Name = "opt" + baseOption.Bvin.Replace("-", ""); rb.Attributes["class"] = "isoption radio" + baseOption.Bvin.Replace("-", ""); rb.Value = o.Bvin.Replace("-", ""); ph.Controls.Add(rb); } ph.Controls.Add(new System.Web.UI.LiteralControl(" " + o.Name + "<br />")); } }
/// <summary> /// /// </summary> protected void mainInterface( ) { if ( this.readMessageWindowSubjectTextLabel == null ) { this.readMessageWindowCcTextLabel=(System.Web.UI.WebControls.Label )this.SharpUI.FindControl("readMessageWindowCcTextLabel"); this.readMessageWindowDateTextLabel=(System.Web.UI.WebControls.Label )this.SharpUI.FindControl("readMessageWindowDateTextLabel"); this.readMessageWindowFromTextLabel=(System.Web.UI.WebControls.Label )this.SharpUI.FindControl("readMessageWindowFromTextLabel"); this.readMessageWindowSubjectTextLabel=(System.Web.UI.WebControls.Label )this.SharpUI.FindControl("readMessageWindowSubjectTextLabel"); this.readMessageWindowToTextLabel=(System.Web.UI.WebControls.Label )this.SharpUI.FindControl("readMessageWindowToTextLabel"); this.newMessageWindowTitle=(System.Web.UI.WebControls.Label )this.SharpUI.FindControl("newMessageWindowTitle"); this.readMessageWindowBodyTextHolder=(System.Web.UI.WebControls.PlaceHolder )this.SharpUI.FindControl("readMessageWindowBodyTextHolder"); this.readMessageWindowAttachmentsHolder=(System.Web.UI.WebControls.PlaceHolder )this.SharpUI.FindControl("readMessageWindowAttachmentsHolder"); ((System.Web.UI.WebControls.HyperLink)this.SharpUI.FindControl("msgtoolbarHeader")).Attributes.Add ("onclick", "window.open('headers.aspx?msgid=" + Server.UrlEncode(msgid) + "', '_blank', 'menubar=no, toolbar=no, resizable=yes, scrollbars=yes, width=500, height=300')"); } // Disable some things this.SharpUI.nextPageImageButton.Enabled = false; this.SharpUI.prevPageImageButton.Enabled = false; }
/// <summary> /// /// </summary> protected void mainInterface( ) { if (this.readMessageWindowSubjectTextLabel == null) { this.readMessageWindowCcTextLabel = (System.Web.UI.WebControls.Label) this.SharpUI.FindControl("readMessageWindowCcTextLabel"); this.readMessageWindowDateTextLabel = (System.Web.UI.WebControls.Label) this.SharpUI.FindControl("readMessageWindowDateTextLabel"); this.readMessageWindowFromTextLabel = (System.Web.UI.WebControls.Label) this.SharpUI.FindControl("readMessageWindowFromTextLabel"); this.readMessageWindowSubjectTextLabel = (System.Web.UI.WebControls.Label) this.SharpUI.FindControl("readMessageWindowSubjectTextLabel"); this.readMessageWindowToTextLabel = (System.Web.UI.WebControls.Label) this.SharpUI.FindControl("readMessageWindowToTextLabel"); this.newMessageWindowTitle = (System.Web.UI.WebControls.Label) this.SharpUI.FindControl("newMessageWindowTitle"); this.readMessageWindowBodyTextHolder = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("readMessageWindowBodyTextHolder"); this.readMessageWindowAttachmentsHolder = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("readMessageWindowAttachmentsHolder"); ((System.Web.UI.WebControls.HyperLink) this.SharpUI.FindControl("msgtoolbarHeader")).Attributes.Add("onclick", "window.open('headers.aspx?msgid=" + Server.UrlEncode(msgid) + "', '_blank', 'menubar=no, toolbar=no, resizable=yes, scrollbars=yes, width=500, height=300')"); } // Disable some things this.SharpUI.nextPageImageButton.Enabled = false; this.SharpUI.prevPageImageButton.Enabled = false; }
/// <summary> /// /// </summary> private void showMessagePanel() { System.Web.UI.WebControls.RegularExpressionValidator rev = (System.Web.UI.WebControls.RegularExpressionValidator) this.SharpUI.FindControl("toemailValidator"); rev.ValidationExpression = @"^" + anmar.SharpMimeTools.ABNF.addr_spec + @"(,\s*" + anmar.SharpMimeTools.ABNF.addr_spec + @")*$"; this.newMessageFromPH = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("newMessageFromPH"); if (!this.IsPostBack) { if (Application["sharpwebmail/send/addressbook"] != null) { System.Collections.SortedList addressbooks = (System.Collections.SortedList)Application["sharpwebmail/send/addressbook"]; if (addressbooks.Count > 0) { System.Web.UI.WebControls.HyperLink addressbook = (System.Web.UI.WebControls.HyperLink) this.SharpUI.FindControl("newMessageWindowToEmailLabel"); addressbook.NavigateUrl = "javascript:window.open('addressbook.aspx', 'addressbook', 'width=400, height=400, resizable=yes, scrollbars=yes');void(true);"; addressbook = (System.Web.UI.WebControls.HyperLink) this.SharpUI.FindControl("msgtoolbarAddressBook"); addressbook.NavigateUrl = "javascript:window.open('addressbook.aspx', 'addressbook', 'width=400, height=400, resizable=yes, scrollbars=yes');void(true);"; addressbook.Visible = true; } } switch ((int)Application["sharpwebmail/login/mode"]) { case 2: this.newMessageFromPH.Visible = true; rev = (System.Web.UI.WebControls.RegularExpressionValidator) this.SharpUI.FindControl("fromemailValidator"); rev.ValidationExpression = "^" + anmar.SharpMimeTools.ABNF.addr_spec + "$"; if (this.fromemail.Value.Length == 0 && Session["DisplayEmail"] != null) { this.fromemail.Value = Session["DisplayEmail"].ToString(); } break; case 1: case 3: default: System.Web.UI.WebControls.Label newMessageWindowFromEmail = (System.Web.UI.WebControls.Label) this.SharpUI.FindControl("newMessageWindowFromEmail"); newMessageWindowFromEmail.Text = User.Identity.Name; break; } } this.newMessagePH.Visible = true; return; }
public void RenderAsControl(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph) { System.Web.UI.WebControls.DropDownList result = new System.Web.UI.WebControls.DropDownList(); result.ID = "opt" + baseOption.Bvin.Replace("-", ""); result.ClientIDMode = System.Web.UI.ClientIDMode.Static; result.CssClass = "isoption"; foreach (OptionItem o in baseOption.Items) { if (o.IsLabel) { result.Items.Add(new System.Web.UI.WebControls.ListItem(o.Name, "systemlabel")); } else { result.Items.Add(new System.Web.UI.WebControls.ListItem(o.Name, o.Bvin.Replace("-", ""))); } } ph.Controls.Add(result); }
public void RenderAsControl(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph) { System.Web.UI.WebControls.TextBox result = new System.Web.UI.WebControls.TextBox(); result.ID = "opt" + baseOption.Bvin.Replace("-", ""); result.ClientIDMode = System.Web.UI.ClientIDMode.Static; string c = this.GetColumns(baseOption); if (c == "") { c = "20"; } string r = this.GetRows(baseOption); if (r == "") { r = "1"; } int rint = 1; int.TryParse(r, out rint); int cint = 20; int.TryParse(c, out cint); int mint = 255; int.TryParse(this.GetMaxLength(baseOption), out mint); result.Rows = rint; result.Columns = cint; result.MaxLength = mint; if (r != "1") { result.TextMode = System.Web.UI.WebControls.TextBoxMode.MultiLine; } ph.Controls.Add(result); }
public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections) { if (ph == null) { return; } if (selections == null) { return; } OptionSelection val = selections.FindByOptionId(baseOption.Bvin); if (val == null) { return; } System.Web.UI.WebControls.TextBox tb = (System.Web.UI.WebControls.TextBox)ph.FindControl("opt" + baseOption.Bvin.Replace("-", "")); if (tb != null) { tb.Text = val.SelectionData; } }
public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph) { OptionSelection result = new OptionSelection(); result.OptionBvin = baseOption.Bvin; System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)ph.FindControl("opt" + baseOption.Bvin.Replace("-", "")); if (ddl != null) { if (ddl.SelectedItem != null) { // Why was I parsing Guid only to return as string? // Safety check maybe? //result.SelectionData = new System.Guid(ddl.SelectedItem.Value).ToString(); // Removed GUID requirement for BVC2004 migration compatibility string temp = ddl.SelectedItem.Value; result.SelectionData = temp; } } return(result); }
/// <summary> /// Restores Page state (content & title) and launch events /// </summary> protected override void OnLoad(EventArgs e) { base.OnLoad(e); //assign as current page Platform.Current.Page = this; //create placeholder for content if (ContentHolder == null) { ContentHolder = new System.Web.UI.WebControls.PlaceHolder(); ContentHolder.ID = "phContent"; base.Form.Controls.Clear(); base.Form.Controls.Add(ContentHolder); } //there is no controller assigned, exit if (Platform.Current.Controller == null) { return; } //get title and content from the state, in case it has a different Page instance if (Platform.Current.PageState != null) { Title = Platform.Current.PageState.Title; Content = Platform.Current.PageState.Content; } //if there is no postback, exit now and skip recovering state and launching events if (!IsPostBack) { return; } //keep track of wich IInputControls had ther value updated so we can reaise IInputControl.OnValueChanged List<IControl> updatedInputControls = new List<IControl>(); //restore state foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__"))) { //get posted value by user string postedValue = Request.Form[postedValueName]; //get control that corresponds to this input IControl control = (IControl) ContentHolder.FindControl(postedValueName); //update control's value if (control is Autocomplete && ((IAutocomplete)control).Value != postedValue) { updatedInputControls.Add(control); ((IAutocomplete) control).Value = postedValue; } else if (control is Calendar && ((ICalendar) control).Value != DateTime.Parse(postedValue)) { updatedInputControls.Add(control); ((ICalendar) control).Value = DateTime.Parse(postedValue); } else if (control is CheckBox && ((ICheckBox)control).Value != (postedValue == "checked")) { updatedInputControls.Add(control); ((ICheckBox) control).Value = postedValue == "checked"; } else if (control is ListPicker && ((IListPicker) control).Value != postedValue) { updatedInputControls.Add(control); ((IListPicker) control).Value = postedValue; } else if (control is PasswordTextBox && ((IPasswordTextBox) control).Value != postedValue) { updatedInputControls.Add(control); ((IPasswordTextBox) control).Value = postedValue; } else if (control is TextArea && ((ITextArea) control).Value != postedValue) { updatedInputControls.Add(control); ((ITextArea) control).Value = postedValue; } else if (control is TextBox && ((ITextBox) control).Value != postedValue) { updatedInputControls.Add(control); ((ITextBox) control).Value = postedValue; } } //raise IInputControl.OnValueChanged events foreach (IControl control in updatedInputControls) { if (control is Autocomplete) { ((Autocomplete) control).RaiseValueChanged(); } else if (control is Calendar) { ((Calendar) control).RaiseValueChanged(); } else if (control is CheckBox) { ((CheckBox) control).RaiseValueChanged(); } else if (control is ListPicker) { ((ListPicker) control).RaiseValueChanged(); } else if (control is PasswordTextBox) { ((PasswordTextBox) control).RaiseValueChanged(); } else if (control is TextArea) { ((TextArea) control).RaiseValueChanged(); } else if (control is TextBox) { ((TextBox) control).RaiseValueChanged(); } } //raise button click events foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__"))) { //get posted value by user string postedValue = Request.Form[postedValueName]; //get control that corresponds to this input IControl control = (IControl) ContentHolder.FindControl(postedValueName); if (control is Button && postedValue == ((Button) control).Text) { ((Button) control).Raise_Click(); } } //raise label & image click events string eventTarget = Request.Form["__EVENTTARGET"]; string eventArgument = Request.Form["__EVENTARGUMENT"]; //get control that corresponds to this input if (!string.IsNullOrWhiteSpace(eventTarget)) { IControl control = (IControl) ContentHolder.FindControl(eventTarget); if (control is LabelButton && eventTarget == control.Name) { ((LabelButton) control).Raise_Click(); } else if (control is IImageButton && eventTarget == control.Name) { ((ImageButton) control).Raise_Click(); } } }
public static void Render(string razorFileVirtualPath, System.Web.UI.WebControls.PlaceHolder ph) { ph.Controls.Add(new System.Web.UI.LiteralControl(Render(razorFileVirtualPath))); }
/// <summary> /// /// </summary> protected void mainInterface( anmar.SharpWebMail.CTNInbox inbox ) { this.newattachmentPH=(System.Web.UI.WebControls.PlaceHolder )this.SharpUI.FindControl("newattachmentPH"); this.attachmentsPH=(System.Web.UI.WebControls.PlaceHolder )this.SharpUI.FindControl("attachmentsPH"); this.confirmationPH=(System.Web.UI.WebControls.PlaceHolder )this.SharpUI.FindControl("confirmationPH"); this.newMessagePH=(System.Web.UI.WebControls.PlaceHolder )this.SharpUI.FindControl("newMessagePH"); this.newMessageWindowAttachFile=( System.Web.UI.HtmlControls.HtmlInputFile )this.SharpUI.FindControl("newMessageWindowAttachFile"); this.newMessageWindowAttachmentsList=(System.Web.UI.WebControls.CheckBoxList )this.SharpUI.FindControl("newMessageWindowAttachmentsList"); this.newMessageWindowAttachmentsAddedList=(System.Web.UI.WebControls.DataList )this.SharpUI.FindControl("newMessageWindowAttachmentsAddedList"); this.FCKEditor = (FredCK.FCKeditorV2.FCKeditor)this.SharpUI.FindControl("FCKEditor"); this.fromname = (System.Web.UI.HtmlControls.HtmlInputText)this.SharpUI.FindControl("fromname"); this.fromemail = (System.Web.UI.HtmlControls.HtmlInputText)this.SharpUI.FindControl("fromemail"); this.subject = (System.Web.UI.HtmlControls.HtmlInputText)this.SharpUI.FindControl("subject"); this.toemail = (System.Web.UI.HtmlControls.HtmlInputText)this.SharpUI.FindControl("toemail"); #if MONO System.Web.UI.WebControls.RequiredFieldValidator rfv = (System.Web.UI.WebControls.RequiredFieldValidator) this.SharpUI.FindControl("ReqbodyValidator"); rfv.Enabled=false; this.Validators.Remove(rfv); #endif this.newMessageWindowConfirmation = (System.Web.UI.WebControls.Label)this.SharpUI.FindControl("newMessageWindowConfirmation"); this.SharpUI.refreshPageImageButton.Click += new System.Web.UI.ImageClickEventHandler(refreshPageButton_Click); // Disable PlaceHolders this.attachmentsPH.Visible = false; this.confirmationPH.Visible = false; // Disable some things this.SharpUI.nextPageImageButton.Enabled = false; this.SharpUI.prevPageImageButton.Enabled = false; // Get mode if ( Page.Request.QueryString["mode"]!=null ) { try { this._message_mode = (anmar.SharpWebMail.UI.MessageMode)System.Enum.Parse(typeof(anmar.SharpWebMail.UI.MessageMode), Page.Request.QueryString["mode"], true); } catch ( System.Exception ){} } // Get message ID System.String msgid = System.Web.HttpUtility.HtmlEncode (Page.Request.QueryString["msgid"]); System.Guid guid = System.Guid.Empty; if ( msgid!=null ) guid = new System.Guid(msgid); if ( !this.IsPostBack && !guid.Equals( System.Guid.Empty) ) { System.Object[] details = inbox[ guid ]; if ( details!=null ) { if ( this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.None) ) this._message_mode = anmar.SharpWebMail.UI.MessageMode.reply; this._headers = (anmar.SharpMimeTools.SharpMimeHeader) details[13]; if ( !this.IsPostBack ) { bool html_content = this.FCKEditor.CheckBrowserCompatibility(); this.subject.Value = System.String.Concat (this.SharpUI.LocalizedRS.GetString(System.String.Concat(this._message_mode, "Prefix")), ":"); if ( details[10].ToString().ToLower().IndexOf (this.subject.Value.ToLower())!=-1 ) { this.subject.Value = details[10].ToString().Trim(); } else { this.subject.Value = System.String.Concat (this.subject.Value, " ", details[10]).Trim(); } // Get the original message inbox.CurrentFolder = details[18].ToString(); System.IO.MemoryStream ms = inbox.GetMessage((int)details[1], msgid); anmar.SharpMimeTools.SharpMessage message = null; if ( ms!=null && ms.CanRead ) { System.String path = null; if ( this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.forward) ) { path = Session["sharpwebmail/read/message/temppath"].ToString(); path = System.IO.Path.Combine (path, msgid); path = System.IO.Path.GetFullPath(path); } bool attachments = false; if ( this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.forward) ) attachments = (bool)Application["sharpwebmail/send/message/forwardattachments"]; message = new anmar.SharpMimeTools.SharpMessage(ms, attachments, html_content, path); } if ( this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.reply) ) { // From name if present on original message's To header // and we don't have it already if ( Session["DisplayName"]==null ) { foreach ( anmar.SharpMimeTools.SharpMimeAddress address in (System.Collections.IEnumerable) details[8] ) { if ( address["address"]!=null && address["address"].Equals( User.Identity.Name ) && address["name"].Length>0 && !address["address"].Equals(address["name"]) ) { this.fromname.Value = address["name"]; break; } } } // To addresses foreach ( anmar.SharpMimeTools.SharpMimeAddress address in (System.Collections.IEnumerable) details[9] ) { if ( address["address"]!=null && !address["address"].Equals( User.Identity.Name ) ) { if ( this.toemail.Value.Length >0 ) this.toemail.Value += ", "; this.toemail.Value += address["address"]; } } } else if ( this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.forward) ) { // If the original message has attachments, preserve them if ( message!=null && message.Attachments!=null && message.Attachments.Count>0 ) { this.bindAttachments(); foreach ( anmar.SharpMimeTools.SharpAttachment attachment in message.Attachments ) { if ( attachment.SavedFile==null ) continue; this.AttachmentSelect(System.IO.Path.Combine(attachment.SavedFile.Directory.Name, attachment.SavedFile.Name)); } this.Attach_Click(this, null); } } // Preserve the original body and some properties if ( message!=null ) { System.Text.StringBuilder sb_body = new System.Text.StringBuilder(); System.String line_end = null; if ( html_content ) line_end = "<br />\r\n"; else line_end = "\r\n"; sb_body.Append(this.SharpUI.LocalizedRS.GetString(System.String.Concat(this._message_mode, "PrefixBody"))); sb_body.Append(line_end); sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowFromNameLabel")); sb_body.Append(" "); sb_body.Append(message.From); sb_body.Append(" [mailto:"); sb_body.Append(message.FromAddress); sb_body.Append("]"); sb_body.Append(line_end); sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowDateLabel")); sb_body.Append(" "); sb_body.Append(message.Date.ToString()); sb_body.Append(line_end); sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowToEmailLabel")); sb_body.Append(" "); if ( html_content ) sb_body.Append(System.Web.HttpUtility.HtmlEncode(message.To.ToString())); else sb_body.Append(message.To); sb_body.Append(line_end); sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowSubjectLabel")); sb_body.Append(" "); sb_body.Append(message.Subject); sb_body.Append(line_end); sb_body.Append(line_end); if ( !message.HasHtmlBody && html_content ) sb_body.Append("<pre>"); sb_body.Append(message.Body); if ( !message.HasHtmlBody && html_content ) sb_body.Append("</pre>"); if ( this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.reply) ) { if ( html_content ) { sb_body.Insert(0, System.String.Concat("<blockquote style=\"", Application["sharpwebmail/send/message/replyquotestyle"] ,"\">")); sb_body.Append("</blockquote>"); } else { sb_body.Insert(0, Application["sharpwebmail/send/message/replyquotechar"].ToString()); sb_body.Replace("\n", System.String.Concat("\n", Application["sharpwebmail/send/message/replyquotechar"])); } } sb_body.Insert(0, line_end); sb_body.Insert(0, " "); this.FCKEditor.Value = sb_body.ToString(); } } details = null; } } else if ( !this.IsPostBack ) { System.String to = Page.Request.QueryString["to"]; if ( to!=null && to.Length>0 ) { this.toemail.Value = to; } } if ( this.fromname.Value.Length>0 || this.IsPostBack ) Session["DisplayName"] = this.fromname.Value; if ( this.fromname.Value.Length==0 && Session["DisplayName"]!=null ) this.fromname.Value = Session["DisplayName"].ToString(); if ( this.fromemail.Value.Length>0 || this.IsPostBack ) Session["DisplayEmail"] = this.fromemail.Value; }
/* * Page Events */ /// <summary> /// /// </summary> protected void Page_Load( System.Object sender, System.EventArgs args ) { if ( this.InboxDataGrid == null ) { this.InboxDataGrid=(System.Web.UI.WebControls.DataGrid )this.SharpUI.FindControl("InboxDataGrid"); this.inboxWindowSearchHolder=(System.Web.UI.WebControls.PlaceHolder)this.SharpUI.FindControl("inboxWindowSearchHolder"); System.String mode = Page.Request.QueryString["mode"]; if ( mode!=null && mode.Equals("trash") ) this.InboxDataGrid.Columns[5].Visible=false; } this.SharpUI.nextPageImageButton.Click += new System.Web.UI.ImageClickEventHandler(nextPageButton_Click); this.SharpUI.prevPageImageButton.Click += new System.Web.UI.ImageClickEventHandler(prevPageButton_Click); this.SharpUI.refreshPageImageButton.Click += new System.Web.UI.ImageClickEventHandler(refreshPageButton_Click); }
public void SetSelectionsInPlaceholder(System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections) { this.Processor.SetSelectionsInPlaceholder(this, ph, selections); }
/// <summary> /// /// </summary> private void showMessagePanel() { System.Web.UI.WebControls.RegularExpressionValidator rev = (System.Web.UI.WebControls.RegularExpressionValidator) this.SharpUI.FindControl("toemailValidator"); rev.ValidationExpression = @"^" + anmar.SharpMimeTools.ABNF.addr_spec + @"(,\s*" + anmar.SharpMimeTools.ABNF.addr_spec + @")*$"; this.newMessageFromPH=(System.Web.UI.WebControls.PlaceHolder )this.SharpUI.FindControl("newMessageFromPH"); if ( !this.IsPostBack ) { if ( Application["sharpwebmail/send/addressbook"]!=null ) { System.Collections.SortedList addressbooks = (System.Collections.SortedList)Application["sharpwebmail/send/addressbook"]; if ( addressbooks.Count>0 ) { System.Web.UI.WebControls.HyperLink addressbook = (System.Web.UI.WebControls.HyperLink)this.SharpUI.FindControl("newMessageWindowToEmailLabel"); addressbook.NavigateUrl = "javascript:window.open('addressbook.aspx', 'addressbook', 'width=400, height=400, resizable=yes, scrollbars=yes');void(true);"; addressbook = (System.Web.UI.WebControls.HyperLink)this.SharpUI.FindControl("msgtoolbarAddressBook"); addressbook.NavigateUrl = "javascript:window.open('addressbook.aspx', 'addressbook', 'width=400, height=400, resizable=yes, scrollbars=yes');void(true);"; addressbook.Visible = true; } } switch ( (int)Application["sharpwebmail/login/mode"] ) { case 2: this.newMessageFromPH.Visible = true; rev = (System.Web.UI.WebControls.RegularExpressionValidator) this.SharpUI.FindControl("fromemailValidator"); rev.ValidationExpression = "^" + anmar.SharpMimeTools.ABNF.addr_spec + "$"; if ( this.fromemail.Value.Length==0 && Session["DisplayEmail"]!=null ) { this.fromemail.Value = Session["DisplayEmail"].ToString(); } break; case 1: case 3: default: System.Web.UI.WebControls.Label newMessageWindowFromEmail = (System.Web.UI.WebControls.Label )this.SharpUI.FindControl("newMessageWindowFromEmail"); newMessageWindowFromEmail.Text = User.Identity.Name; break; } } this.newMessagePH.Visible = true; return; }
public void RenderAsControl(System.Web.UI.WebControls.PlaceHolder ph) { this.Processor.RenderAsControl(this, ph); }
/// <summary> /// Restores Page state (content & title) and launch events /// <para xml:lang="es">Restaura el estado de la pagina (Contenido y titulo) y lanza eventos</para> /// </summary> protected override void OnLoad(EventArgs e) { base.OnLoad(e); //assign as current page Platform.Current.Page = this; //load javascript dependencies Page.ClientScript.RegisterClientScriptInclude("jquery", ResolveUrl("~/js/jquery.js")); Page.ClientScript.RegisterClientScriptInclude("jquery-ui", ResolveUrl("~/js/jquery-ui.js")); Page.ClientScript.RegisterClientScriptInclude("PageSize", ResolveUrl("~/js/PageSize.js")); //if this is the first request, get page size if (!IsPostBack && Width == 0 && Height == 0) { string pageSizeJS = @" <script type='text/javascript'> $(document).ready ( function() { SetPageSize(); } ); </script>"; //register javascripts Page.ClientScript.RegisterStartupScript(this.GetType(), "SetPageSize", pageSizeJS); return; } //create placeholder for content if (ContentHolder == null) { ContentHolder = new System.Web.UI.WebControls.PlaceHolder(); ContentHolder.ID = "phContent"; base.Form.Controls.Add(ContentHolder); } //there is no controller assigned, exit if (Platform.Current.Controller == null) { return; } //get title and content from the state, in case it has a different Page instance if (Platform.Current.PageState != null) { Title = Platform.Current.PageState.Title; Content = Platform.Current.PageState.Content; } //if there is no postback, exit now and skip recovering state and launching events if (!IsPostBack) { return; } //keep track of wich IInputControls had ther value updated so we can reaise IInputControl.OnValueChanged List<IControl> updatedInputControls = new List<IControl>(); //restore state foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__"))) { //get posted value by user string postedValue = Request.Form[postedValueName]; //get control that corresponds to this input IControl control = ContentHolder.FindControl(postedValueName) as IControl; if(control == null) { continue; } //update control's value if (control is Autocomplete && ((IAutocomplete)control).Value != postedValue) { updatedInputControls.Add(control); ((IAutocomplete) control).Value = postedValue; } else if (control is Calendar && ((ICalendar) control).Value != DateTime.Parse(postedValue)) { updatedInputControls.Add(control); ((ICalendar) control).Value = DateTime.Parse(postedValue); } else if (control is CheckBox && ((ICheckBox) control).Value != (postedValue == "on")) { updatedInputControls.Add(control); ((ICheckBox) control).Value = postedValue == "on"; } else if (control is ListPicker && ((IListPicker) control).Value != postedValue) { updatedInputControls.Add(control); ((IListPicker) control).Value = postedValue; } else if (control is PasswordTextBox && ((IPasswordTextBox) control).Value != postedValue) { updatedInputControls.Add(control); ((IPasswordTextBox) control).Value = postedValue; } else if (control is TextArea && ((ITextArea) control).Value != postedValue) { updatedInputControls.Add(control); ((ITextArea) control).Value = postedValue; } else if (control is TextBox && ((ITextBox) control).Value != postedValue) { updatedInputControls.Add(control); ((ITextBox) control).Value = postedValue; } } //raise IInputControl.OnValueChanged events foreach (IControl control in updatedInputControls) { if (control is Autocomplete) { ((Autocomplete) control).RaiseValueChanged(); } else if (control is Calendar) { ((Calendar) control).RaiseValueChanged(); } else if (control is CheckBox) { ((CheckBox) control).RaiseValueChanged(); } else if (control is ListPicker) { ((ListPicker) control).RaiseValueChanged(); } else if (control is PasswordTextBox) { ((PasswordTextBox) control).RaiseValueChanged(); } else if (control is TextArea) { ((TextArea) control).RaiseValueChanged(); } else if (control is TextBox) { ((TextBox) control).RaiseValueChanged(); } } //raise button click events foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__"))) { //get posted value by user string postedValue = Request.Form[postedValueName]; //get control that corresponds to this input //get control that corresponds to this input IControl control = ContentHolder.FindControl(postedValueName) as IControl; if (control == null) { continue; } if (control is Button && postedValue == ((Button) control).Text) { ((Button) control).Raise_Click(); } } //raise labelbutton, checkbox & image click events string eventTarget = Request.Form["__EVENTTARGET"]; string eventArgument = Request.Form["__EVENTARGUMENT"]; //get control that corresponds to this input if (!string.IsNullOrWhiteSpace(eventTarget)) { IControl control = (IControl) ContentHolder.FindControl(eventTarget); if (control is LabelButton && eventTarget == control.Name) { ((LabelButton) control).Raise_Click(); } else if (control is IImageButton && eventTarget == control.Name) { ((ImageButton) control).Raise_Click(); } else if (control is ICheckBox && eventTarget == control.Name && !updatedInputControls.Contains(control)) //check updatedInputControls collection because checkbox is causing double event raising { ((ICheckBox) control).Value = !((ICheckBox) control).Value; ((CheckBox) control).RaiseValueChanged(); } } }
public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections) { // do nothing; }
public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph) { return(null); }
public void RenderAsControl(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph) { System.Web.UI.LiteralControl result = new System.Web.UI.LiteralControl(baseOption.Settings.GetSettingOrEmpty("html")); ph.Controls.Add(result); }
/// <summary> /// Restores Page state (content & title) and launch events /// <para xml:lang="es">Restaura el estado de la pagina (Contenido y titulo) y lanza eventos</para> /// </summary> protected override void OnLoad(EventArgs e) { base.OnLoad(e); //assign as current page Platform.Current.Page = this; //load javascript dependencies Page.ClientScript.RegisterClientScriptInclude("jquery", ResolveUrl("~/js/jquery.js")); Page.ClientScript.RegisterClientScriptInclude("jquery-ui", ResolveUrl("~/js/jquery-ui.js")); Page.ClientScript.RegisterClientScriptInclude("PageSize", ResolveUrl("~/js/PageSize.js")); //if this is the first request, get page size if (!IsPostBack && Width == 0 && Height == 0) { string pageSizeJS = @" <script type='text/javascript'> $(document).ready ( function() { SetPageSize(); } ); </script>" ; //register javascripts Page.ClientScript.RegisterStartupScript(this.GetType(), "SetPageSize", pageSizeJS); return; } //create placeholder for content if (ContentHolder == null) { ContentHolder = new System.Web.UI.WebControls.PlaceHolder(); ContentHolder.ID = "phContent"; base.Form.Controls.Add(ContentHolder); } //there is no controller assigned, exit if (Platform.Current.Controller == null) { return; } //get title and content from the state, in case it has a different Page instance if (Platform.Current.PageState != null) { Title = Platform.Current.PageState.Title; Content = Platform.Current.PageState.Content; } //if there is no postback, exit now and skip recovering state and launching events if (!IsPostBack) { return; } //keep track of wich IInputControls had ther value updated so we can reaise IInputControl.OnValueChanged List <IControl> updatedInputControls = new List <IControl>(); //restore state foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__"))) { //get posted value by user string postedValue = Request.Form[postedValueName]; //get control that corresponds to this input IControl control = ContentHolder.FindControl(postedValueName) as IControl; if (control == null) { continue; } //update control's value if (control is Autocomplete && ((IAutocomplete)control).Value != postedValue) { updatedInputControls.Add(control); ((IAutocomplete)control).Value = postedValue; } else if (control is Calendar && ((ICalendar)control).Value != DateTime.Parse(postedValue)) { updatedInputControls.Add(control); ((ICalendar)control).Value = DateTime.Parse(postedValue); } else if (control is CheckBox && ((ICheckBox)control).Value != (postedValue == "on")) { updatedInputControls.Add(control); ((ICheckBox)control).Value = postedValue == "on"; } else if (control is ListPicker && ((IListPicker)control).Value != postedValue) { updatedInputControls.Add(control); ((IListPicker)control).Value = postedValue; } else if (control is PasswordTextBox && ((IPasswordTextBox)control).Value != postedValue) { updatedInputControls.Add(control); ((IPasswordTextBox)control).Value = postedValue; } else if (control is TextArea && ((ITextArea)control).Value != postedValue) { updatedInputControls.Add(control); ((ITextArea)control).Value = postedValue; } else if (control is TextBox && ((ITextBox)control).Value != postedValue) { updatedInputControls.Add(control); ((ITextBox)control).Value = postedValue; } } //raise IInputControl.OnValueChanged events foreach (IControl control in updatedInputControls) { if (control is Autocomplete) { ((Autocomplete)control).RaiseValueChanged(); } else if (control is Calendar) { ((Calendar)control).RaiseValueChanged(); } else if (control is CheckBox) { ((CheckBox)control).RaiseValueChanged(); } else if (control is ListPicker) { ((ListPicker)control).RaiseValueChanged(); } else if (control is PasswordTextBox) { ((PasswordTextBox)control).RaiseValueChanged(); } else if (control is TextArea) { ((TextArea)control).RaiseValueChanged(); } else if (control is TextBox) { ((TextBox)control).RaiseValueChanged(); } } //raise button click events foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__"))) { //get posted value by user string postedValue = Request.Form[postedValueName]; //get control that corresponds to this input //get control that corresponds to this input IControl control = ContentHolder.FindControl(postedValueName) as IControl; if (control == null) { continue; } if (control is Button && postedValue == ((Button)control).Text) { ((Button)control).Raise_Click(); } } //raise labelbutton, checkbox & image click events string eventTarget = Request.Form["__EVENTTARGET"]; string eventArgument = Request.Form["__EVENTARGUMENT"]; //get control that corresponds to this input if (!string.IsNullOrWhiteSpace(eventTarget)) { IControl control = (IControl)ContentHolder.FindControl(eventTarget); if (control is LabelButton && eventTarget == control.Name) { ((LabelButton)control).Raise_Click(); } else if (control is IImageButton && eventTarget == control.Name) { ((ImageButton)control).Raise_Click(); } else if (control is ICheckBox && eventTarget == control.Name && !updatedInputControls.Contains(control)) //check updatedInputControls collection because checkbox is causing double event raising { ((ICheckBox)control).Value = !((ICheckBox)control).Value; ((CheckBox)control).RaiseValueChanged(); } } }
public Catalog.OptionSelection ParseFromPlaceholder(System.Web.UI.WebControls.PlaceHolder ph) { return(this.Processor.ParseFromPlaceholder(this, ph)); }
private void decodeMessage(anmar.SharpMimeTools.SharpMessage message, System.Web.UI.WebControls.PlaceHolder entity) { System.Web.UI.HtmlControls.HtmlGenericControl body = new System.Web.UI.HtmlControls.HtmlGenericControl("span"); // RFC 2392 message.SetUrlBase(System.String.Concat("download.aspx?msgid=", Server.UrlEncode(msgid), "&name=[Name]&i=1")); // Html body if (message.HasHtmlBody) { body.Attributes["class"] = "XPFormText"; if ((int)Application["sharpwebmail/read/message/sanitizer_mode"] == 1) { body.InnerHtml = anmar.SharpWebMail.BasicSanitizer.SanitizeHTML(message.Body, anmar.SharpWebMail.SanitizerMode.CommentBlocks | anmar.SharpWebMail.SanitizerMode.RemoveEvents); } else { body.InnerHtml = message.Body; } // Text body } else { body.TagName = "pre"; body.InnerText = message.Body; } entity.Controls.Add(body); // Attachments if (message.Attachments != null) { bool inline_added = false; foreach (anmar.SharpMimeTools.SharpAttachment item in message.Attachments) { if (item.SavedFile == null) { continue; } System.Web.UI.HtmlControls.HtmlAnchor attachment = new System.Web.UI.HtmlControls.HtmlAnchor(); attachment.Attributes["class"] = "XPDownload"; attachment.Title = System.String.Concat(item.SavedFile.Name, " (", item.Size, " bytes)"); attachment.InnerText = attachment.Title; System.String urlstring = System.String.Concat("download.aspx?msgid=", Server.UrlEncode(msgid), "&name=", Server.UrlEncode(item.SavedFile.Name), "&i="); attachment.HRef = urlstring; this.readMessageWindowAttachmentsHolder.Controls.Add(attachment); // Inline attachment if (item.Inline) { if (item.MimeTopLevelMediaType == anmar.SharpMimeTools.MimeTopLevelMediaType.image && (item.MimeMediaSubType == "gif" || item.MimeMediaSubType == "jpg" || item.MimeMediaSubType == "png")) { System.Web.UI.HtmlControls.HtmlImage image = new System.Web.UI.HtmlControls.HtmlImage(); image.Src = System.String.Concat(urlstring, "1"); image.Alt = attachment.Name; if (!inline_added) { entity.Controls.Add(new System.Web.UI.HtmlControls.HtmlGenericControl("hr")); inline_added = true; } entity.Controls.Add(image); } } } } }
/// <summary> /// Restores Page state (content & title) and launch events /// </summary> protected override void OnLoad(EventArgs e) { base.OnLoad(e); //assign as current page Platform.Current.Page = this; //create placeholder for content if (ContentHolder == null) { ContentHolder = new System.Web.UI.WebControls.PlaceHolder(); ContentHolder.ID = "phContent"; base.Form.Controls.Clear(); base.Form.Controls.Add(ContentHolder); } //there is no controller assigned, exit if (Platform.Current.Controller == null) { return; } //get title and content from the state, in case it has a different Page instance if (Platform.Current.PageState != null) { Title = Platform.Current.PageState.Title; Content = Platform.Current.PageState.Content; } //if there is no postback, exit now and skip recovering state and launching events if (!IsPostBack) { return; } //keep track of wich IInputControls had ther value updated so we can reaise IInputControl.OnValueChanged List <IControl> updatedInputControls = new List <IControl>(); //restore state foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__"))) { //get posted value by user string postedValue = Request.Form[postedValueName]; //get control that corresponds to this input IControl control = (IControl)ContentHolder.FindControl(postedValueName); //update control's value if (control is Autocomplete && ((IAutocomplete)control).Value != postedValue) { updatedInputControls.Add(control); ((IAutocomplete)control).Value = postedValue; } else if (control is Calendar && ((ICalendar)control).Value != DateTime.Parse(postedValue)) { updatedInputControls.Add(control); ((ICalendar)control).Value = DateTime.Parse(postedValue); } else if (control is CheckBox && ((ICheckBox)control).Value != (postedValue == "checked")) { updatedInputControls.Add(control); ((ICheckBox)control).Value = postedValue == "checked"; } else if (control is ListPicker && ((IListPicker)control).Value != postedValue) { updatedInputControls.Add(control); ((IListPicker)control).Value = postedValue; } else if (control is PasswordTextBox && ((IPasswordTextBox)control).Value != postedValue) { updatedInputControls.Add(control); ((IPasswordTextBox)control).Value = postedValue; } else if (control is TextArea && ((ITextArea)control).Value != postedValue) { updatedInputControls.Add(control); ((ITextArea)control).Value = postedValue; } else if (control is TextBox && ((ITextBox)control).Value != postedValue) { updatedInputControls.Add(control); ((ITextBox)control).Value = postedValue; } } //raise IInputControl.OnValueChanged events foreach (IControl control in updatedInputControls) { if (control is Autocomplete) { ((Autocomplete)control).RaiseValueChanged(); } else if (control is Calendar) { ((Calendar)control).RaiseValueChanged(); } else if (control is CheckBox) { ((CheckBox)control).RaiseValueChanged(); } else if (control is ListPicker) { ((ListPicker)control).RaiseValueChanged(); } else if (control is PasswordTextBox) { ((PasswordTextBox)control).RaiseValueChanged(); } else if (control is TextArea) { ((TextArea)control).RaiseValueChanged(); } else if (control is TextBox) { ((TextBox)control).RaiseValueChanged(); } } //raise button click events foreach (string postedValueName in Request.Form.AllKeys.Where(k => !k.StartsWith("__"))) { //get posted value by user string postedValue = Request.Form[postedValueName]; //get control that corresponds to this input IControl control = (IControl)ContentHolder.FindControl(postedValueName); if (control is Button && postedValue == ((Button)control).Text) { ((Button)control).Raise_Click(); } } //raise label & image click events string eventTarget = Request.Form["__EVENTTARGET"]; string eventArgument = Request.Form["__EVENTARGUMENT"]; //get control that corresponds to this input if (!string.IsNullOrWhiteSpace(eventTarget)) { IControl control = (IControl)ContentHolder.FindControl(eventTarget); if (control is LabelButton && eventTarget == control.Name) { ((LabelButton)control).Raise_Click(); } else if (control is IImageButton && eventTarget == control.Name) { ((ImageButton)control).Raise_Click(); } } }
/// <summary> /// /// </summary> protected void mainInterface(anmar.SharpWebMail.CTNInbox inbox) { this.newattachmentPH = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("newattachmentPH"); this.attachmentsPH = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("attachmentsPH"); this.confirmationPH = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("confirmationPH"); this.newMessagePH = (System.Web.UI.WebControls.PlaceHolder) this.SharpUI.FindControl("newMessagePH"); this.newMessageWindowAttachFile = (System.Web.UI.HtmlControls.HtmlInputFile) this.SharpUI.FindControl("newMessageWindowAttachFile"); this.newMessageWindowAttachmentsList = (System.Web.UI.WebControls.CheckBoxList) this.SharpUI.FindControl("newMessageWindowAttachmentsList"); this.newMessageWindowAttachmentsAddedList = (System.Web.UI.WebControls.DataList) this.SharpUI.FindControl("newMessageWindowAttachmentsAddedList"); this.FCKEditor = (FredCK.FCKeditorV2.FCKeditor) this.SharpUI.FindControl("FCKEditor"); this.fromname = (System.Web.UI.HtmlControls.HtmlInputText) this.SharpUI.FindControl("fromname"); this.fromemail = (System.Web.UI.HtmlControls.HtmlInputText) this.SharpUI.FindControl("fromemail"); this.subject = (System.Web.UI.HtmlControls.HtmlInputText) this.SharpUI.FindControl("subject"); this.toemail = (System.Web.UI.HtmlControls.HtmlInputText) this.SharpUI.FindControl("toemail"); #if MONO System.Web.UI.WebControls.RequiredFieldValidator rfv = (System.Web.UI.WebControls.RequiredFieldValidator) this.SharpUI.FindControl("ReqbodyValidator"); rfv.Enabled = false; this.Validators.Remove(rfv); #endif this.newMessageWindowConfirmation = (System.Web.UI.WebControls.Label) this.SharpUI.FindControl("newMessageWindowConfirmation"); this.SharpUI.refreshPageImageButton.Click += new System.Web.UI.ImageClickEventHandler(refreshPageButton_Click); // Disable PlaceHolders this.attachmentsPH.Visible = false; this.confirmationPH.Visible = false; // Disable some things this.SharpUI.nextPageImageButton.Enabled = false; this.SharpUI.prevPageImageButton.Enabled = false; // Get mode if (Page.Request.QueryString["mode"] != null) { try { this._message_mode = (anmar.SharpWebMail.UI.MessageMode)System.Enum.Parse(typeof(anmar.SharpWebMail.UI.MessageMode), Page.Request.QueryString["mode"], true); } catch (System.Exception) {} } // Get message ID System.String msgid = System.Web.HttpUtility.HtmlEncode(Page.Request.QueryString["msgid"]); System.Guid guid = System.Guid.Empty; if (msgid != null) { guid = new System.Guid(msgid); } if (!this.IsPostBack && !guid.Equals(System.Guid.Empty)) { System.Object[] details = inbox[guid]; if (details != null) { if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.None)) { this._message_mode = anmar.SharpWebMail.UI.MessageMode.reply; } this._headers = (anmar.SharpMimeTools.SharpMimeHeader)details[13]; if (!this.IsPostBack) { bool html_content = this.FCKEditor.CheckBrowserCompatibility(); this.subject.Value = System.String.Concat(this.SharpUI.LocalizedRS.GetString(System.String.Concat(this._message_mode, "Prefix")), ":"); if (details[10].ToString().ToLower().IndexOf(this.subject.Value.ToLower()) != -1) { this.subject.Value = details[10].ToString().Trim(); } else { this.subject.Value = System.String.Concat(this.subject.Value, " ", details[10]).Trim(); } // Get the original message inbox.CurrentFolder = details[18].ToString(); System.IO.MemoryStream ms = inbox.GetMessage((int)details[1], msgid); anmar.SharpMimeTools.SharpMessage message = null; if (ms != null && ms.CanRead) { System.String path = null; if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.forward)) { path = Session["sharpwebmail/read/message/temppath"].ToString(); path = System.IO.Path.Combine(path, msgid); path = System.IO.Path.GetFullPath(path); } bool attachments = false; if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.forward)) { attachments = (bool)Application["sharpwebmail/send/message/forwardattachments"]; } message = new anmar.SharpMimeTools.SharpMessage(ms, attachments, html_content, path); ms.Close(); } ms = null; if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.reply)) { // From name if present on original message's To header // and we don't have it already if (Session["DisplayName"] == null) { foreach (anmar.SharpMimeTools.SharpMimeAddress address in (System.Collections.IEnumerable)details[8]) { if (address["address"] != null && address["address"].Equals(User.Identity.Name) && address["name"].Length > 0 && !address["address"].Equals(address["name"])) { this.fromname.Value = address["name"]; break; } } } // To addresses foreach (anmar.SharpMimeTools.SharpMimeAddress address in (System.Collections.IEnumerable)details[9]) { if (address["address"] != null && !address["address"].Equals(User.Identity.Name)) { if (this.toemail.Value.Length > 0) { this.toemail.Value += ", "; } this.toemail.Value += address["address"]; } } } else if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.forward)) { // If the original message has attachments, preserve them if (message != null && message.Attachments != null && message.Attachments.Count > 0) { this.bindAttachments(); foreach (anmar.SharpMimeTools.SharpAttachment attachment in message.Attachments) { if (attachment.SavedFile == null) { continue; } this.AttachmentSelect(System.IO.Path.Combine(attachment.SavedFile.Directory.Name, attachment.SavedFile.Name)); } this.Attach_Click(this, null); } } // Preserve the original body and some properties if (message != null) { System.Text.StringBuilder sb_body = new System.Text.StringBuilder(); System.String line_end = null; if (html_content) { line_end = "<br />\r\n"; } else { line_end = "\r\n"; } sb_body.Append(this.SharpUI.LocalizedRS.GetString(System.String.Concat(this._message_mode, "PrefixBody"))); sb_body.Append(line_end); sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowFromNameLabel")); sb_body.Append(" "); sb_body.Append(message.From); sb_body.Append(" [mailto:"); sb_body.Append(message.FromAddress); sb_body.Append("]"); sb_body.Append(line_end); sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowDateLabel")); sb_body.Append(" "); sb_body.Append(message.Date.ToString()); sb_body.Append(line_end); sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowToEmailLabel")); sb_body.Append(" "); if (html_content) { sb_body.Append(System.Web.HttpUtility.HtmlEncode(message.To.ToString())); } else { sb_body.Append(message.To); } sb_body.Append(line_end); sb_body.Append(this.SharpUI.LocalizedRS.GetString("newMessageWindowSubjectLabel")); sb_body.Append(" "); sb_body.Append(message.Subject); sb_body.Append(line_end); sb_body.Append(line_end); if (!message.HasHtmlBody && html_content) { sb_body.Append("<pre>"); } sb_body.Append(message.Body); if (!message.HasHtmlBody && html_content) { sb_body.Append("</pre>"); } if (this._message_mode.Equals(anmar.SharpWebMail.UI.MessageMode.reply)) { if (html_content) { sb_body.Insert(0, System.String.Concat("<blockquote style=\"", Application["sharpwebmail/send/message/replyquotestyle"], "\">")); sb_body.Append("</blockquote>"); } else { sb_body.Insert(0, Application["sharpwebmail/send/message/replyquotechar"].ToString()); sb_body.Replace("\n", System.String.Concat("\n", Application["sharpwebmail/send/message/replyquotechar"])); } } sb_body.Insert(0, line_end); sb_body.Insert(0, " "); this.FCKEditor.Value = sb_body.ToString(); } } details = null; } } else if (!this.IsPostBack) { System.String to = Page.Request.QueryString["to"]; if (to != null && to.Length > 0) { this.toemail.Value = to; } } if (this.fromname.Value.Length > 0 || this.IsPostBack) { Session["DisplayName"] = this.fromname.Value; } if (this.fromname.Value.Length == 0 && Session["DisplayName"] != null) { this.fromname.Value = Session["DisplayName"].ToString(); } if (this.fromemail.Value.Length > 0 || this.IsPostBack) { Session["DisplayEmail"] = this.fromemail.Value; } }
public override void Add_Main_Viewer_Section(System.Web.UI.WebControls.PlaceHolder MainPlaceHolder, Custom_Tracer Tracer) { // do nothing }
private void decodeMessage( anmar.SharpMimeTools.SharpMimeMessage mm, System.Web.UI.WebControls.PlaceHolder entity ) { System.String inline = System.String.Empty; switch ( mm.Header.TopLevelMediaType ) { case anmar.SharpMimeTools.MimeTopLevelMediaType.multipart: case anmar.SharpMimeTools.MimeTopLevelMediaType.message: // TODO: allow other subtypes of "message" // Only message/rfc822 allowed, other subtypes ignored if ( mm.Header.TopLevelMediaType.Equals(anmar.SharpMimeTools.MimeTopLevelMediaType.message) && !mm.Header.SubType.Equals("rfc822") ) break; if ( mm.Header.SubType.Equals ("alternative") ) { if ( mm.PartsCount>0 ) { this.decodeMessage ( mm.GetPart(mm.PartsCount-1), entity); } // TODO: Take into account each subtype of "multipart" } else if ( mm.PartsCount>0 ) { System.Web.UI.WebControls.PlaceHolder nestedentity = new System.Web.UI.WebControls.PlaceHolder (); System.Collections.IEnumerator enu = mm.GetEnumerator(); while ( enu.MoveNext() ) { this.decodeMessage ((anmar.SharpMimeTools.SharpMimeMessage) enu.Current, nestedentity); } entity.Controls.Add (nestedentity); } break; case anmar.SharpMimeTools.MimeTopLevelMediaType.text: if ( ( mm.Disposition==null || !mm.Disposition.Equals("attachment") ) && ( mm.Header.SubType.Equals("plain") || mm.Header.SubType.Equals("html") ) ) { System.Web.UI.WebControls.Label label = new System.Web.UI.WebControls.Label (); label.Text = mm.BodyDecoded; if ( mm.IsTextBrowserDisplay ) { label.Text = System.Web.HttpUtility.HtmlEncode (label.Text); label.Text = label.Text.Insert (0, "<pre id=\"message\">"); label.Text = label.Text.Insert (label.Text.Length, "</pre>"); } else { label.CssClass = "XPFormText"; if ( (int)Application["sharpwebmail/read/message/sanitizer_mode"]==1 ) { label.Text = anmar.SharpWebMail.BasicSanitizer.SanitizeHTML(label.Text, anmar.SharpWebMail.SanitizerMode.CommentBlocks|anmar.SharpWebMail.SanitizerMode.RemoveEvents); } } entity.Controls.Add (label); break; } else { goto case anmar.SharpMimeTools.MimeTopLevelMediaType.application; } case anmar.SharpMimeTools.MimeTopLevelMediaType.application: case anmar.SharpMimeTools.MimeTopLevelMediaType.audio: case anmar.SharpMimeTools.MimeTopLevelMediaType.image: case anmar.SharpMimeTools.MimeTopLevelMediaType.video: System.Web.UI.WebControls.HyperLink attachment = new System.Web.UI.WebControls.HyperLink (); System.Web.UI.WebControls.Image image = null; attachment.CssClass = "XPDownload"; if ( mm.Name!=null ) attachment.Text = System.String.Format ("{0} ({1} bytes)", System.IO.Path.GetFileName(mm.Name), mm.Size); if ( Session["sharpwebmail/read/message/temppath"]!=null ) { System.String path = Session["sharpwebmail/read/message/temppath"].ToString(); path = System.IO.Path.Combine (path, msgid); // Dump file contents System.IO.FileInfo file = mm.DumpBody ( path, true ); if ( file!=null && file.Exists ) { System.String urlstring = System.String.Format("download.aspx?msgid={0}&name={1}&i={2}", Server.UrlEncode(msgid), Server.UrlEncode(file.Name), inline); if ( mm.Disposition!=null && mm.Disposition.Equals("inline") ) { inline = "1"; if ( mm.Header.TopLevelMediaType.Equals(anmar.SharpMimeTools.MimeTopLevelMediaType.image) && ( mm.Header.SubType.Equals("gif") || mm.Header.SubType.Equals("jpg") || mm.Header.SubType.Equals("png")) ) { image = new System.Web.UI.WebControls.Image (); image.ImageUrl = urlstring; } } attachment.NavigateUrl = urlstring; attachment.Text = System.String.Format ("{0} ({1} bytes)", file.Name, file.Length); } } this.readMessageWindowAttachmentsHolder.Controls.Add (attachment); // Display inline image if ( image!=null ) { entity.Controls.Add (image); } break; default: break; } }