Пример #1
0
 /// <summary>
 /// Checkbox list DataBind
 /// </summary>
 /// <param name="chControl">chList</param>
 /// <param name="dt">Datasource Datatable</param>
 /// <param name="DataTextField">Görüntülenecek Hücre</param>
 /// <param name="DataValueField">Value Hücre</param>
 public static void BindCheckBoxList(ref System.Web.UI.WebControls.CheckBoxList chControl, DataTable dt, string DataTextField, string DataValueField)
 {
     chControl.DataTextField  = DataTextField;
     chControl.DataValueField = DataValueField;
     chControl.DataSource     = dt;
     chControl.DataBind();
 }
Пример #2
0
        public Int64 InsertMultpleFromCity(Int64 HeadIdno, System.Web.UI.WebControls.CheckBoxList chklistFromcity)
        {
            Int64 fromcityDetlIdno = 0;

            try
            {
                using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
                {
                    for (int i = 0; i < chklistFromcity.Items.Count; i++)
                    {
                        if (chklistFromcity.Items[i].Selected == true)
                        {
                            tblFrmCityDetl obj = new tblFrmCityDetl();
                            obj.User_Idno    = HeadIdno;
                            obj.FrmCity_Idno = Convert.ToInt32(chklistFromcity.Items[i].Value);
                            db.AddTotblFrmCityDetls(obj);
                            db.SaveChanges();
                            fromcityDetlIdno = obj.FrmCityDetl_Idno;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(fromcityDetlIdno);
        }
Пример #3
0
 /// <summary>
 /// 复选框数据加载
 /// </summary>
 /// <param name="DDL_Items"></param>
 /// <param name="tablename">表名</param>
 /// <param name="mtext">名称字段</param>
 /// <param name="mvalue">编号字段</param>
 public static void LoadSelection(ref System.Web.UI.WebControls.CheckBoxList DDL_Items, string tablename, string mtext, string mvalue)
 {
     DDL_Items.DataSource = GetSelections(tablename);
     DDL_Items.Items.Clear();
     DDL_Items.SelectedIndex  = -1;
     DDL_Items.DataTextField  = mtext;
     DDL_Items.DataValueField = mvalue;
     DDL_Items.DataBind();
 }
Пример #4
0
 /// <summary>
 /// 根据值设定复选框选中项
 /// </summary>
 /// <param name="DDL_Items">复选框</param>
 /// <param name="Value">值</param>
 public static void SetIndex(ref System.Web.UI.WebControls.CheckBoxList DDL_Items, string Value)
 {
     for (int i = 0; i < DDL_Items.Items.Count; i++)
     {
         if (DDL_Items.Items[i].Value.Trim() == Value.Trim())
         {
             DDL_Items.Items[i].Selected = true;
         }
     }
 }
Пример #5
0
        public string Sbox(System.Web.UI.WebControls.CheckBoxList boxlist, int a)
        {
            string str = a + ",,";

            for (int i = 0; i <= boxlist.Items.Count - 1; i++)
            {
                if (boxlist.Items[i].Selected == true)
                {
                    str += i.ToString() + ",";
                }
            }
            return(str);
        }
Пример #6
0
        /// <summary>
        /// CheckBoxList控件翻译,从数据库中取值
        /// </summary>
        /// <param name="button">要翻译的服务器控件</param>
        /// <param name="columns">二维数组型参数,第二维第一个为字典键值,第二个为默认值</param>
        public static void TranslationCheckBoxListDB(System.Web.UI.WebControls.CheckBoxList chkl, string[][] items)
        {
            string tlText = string.Empty;

            for (int i = 0; i < items.Length; i++)
            {
                tlText = Translate(items[i][0]);
                if (tlText == "")
                {
                    tlText = items[i][1];
                }
                chkl.Items[i].Text = tlText;
            }
        }
Пример #7
0
        /// <summary>
        /// Resolves the values.
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="listControl">The list control.</param>
        /// <returns></returns>
        private string ResolveValues(string values, System.Web.UI.WebControls.CheckBoxList checkBoxList)
        {
            var resolvedValues = new List <string>();

            foreach (string value in values.Split(';'))
            {
                var item = checkBoxList.Items.FindByValue(value);
                if (item != null)
                {
                    resolvedValues.Add(item.Text);
                }
            }

            return(resolvedValues.AsDelimited(", "));
        }
Пример #8
0
        /// <summary>
        /// 返回CheckBoxList的所有选中的值,返回类似1,2,3,4,5
        /// </summary>
        /// <param name="cb">CheckBoxList控件</param>
        /// <returns></returns>
        public static string getCheckBoxListSelectValues(System.Web.UI.WebControls.CheckBoxList cb)
        {
            StringBuilder sb     = new StringBuilder();
            string        result = string.Empty;

            for (int i = 0; i < cb.Items.Count; i++)
            {
                if (cb.Items[i].Selected)
                {
                    sb.Append(cb.Items[i].Value + ",");
                }
            }
            result = sb.ToString();
            return(result.TrimEnd(','));
        }
Пример #9
0
        ModificarCheckBox(System.Web.UI.WebControls.CheckBoxList CBL)
        {
            IList <Core.LogicaNegocio.Entidades.Permiso> _permiso =
                new List <Core.LogicaNegocio.Entidades.Permiso>();

            for (int j = 0; j < _TamañoLista; j++)
            {
                if (CBL.Items[j].Selected == true)
                {
                    Core.LogicaNegocio.Entidades.Permiso permiso = new Permiso();

                    permiso.IdPermiso = Int32.Parse(CBL.Items[j].Value);

                    _permiso.Add(permiso);
                }
            }
            return(_permiso);
        }
Пример #10
0
        /// <summary>
        /// 多选控件选中值
        /// </summary>
        /// <param name="cbl">多选控件</param>
        /// <param name="defaultVal">默认值</param>
        /// <returns></returns>
        public static string GetValueCheckBoxList(System.Web.UI.WebControls.CheckBoxList cbl, string defaultVal)
        {
            string valStr = "";

            for (int i = 0; i < cbl.Items.Count; i++)
            {
                if (cbl.Items[i].Value == "" || !cbl.Items[i].Selected)
                {
                    continue;
                }
                valStr += cbl.Items[i].Value + ",";
            }
            valStr = EKGetString.RemoveEnd(valStr, ",");
            if (valStr == "")
            {
                return(defaultVal);
            }
            return(valStr);
        }
Пример #11
0
        /// <summary>
        /// Gets the check box list values by evaluating the posted form values for each input item in the rendered checkbox list.
        /// This is required because of a bug in ASP.NET that results in the Selected property for CheckBoxList items to not be
        /// set correctly on a postback.
        /// </summary>
        /// <param name="checkBoxList">The check box list.</param>
        /// <returns></returns>
        private string GetCheckBoxListValues(System.Web.UI.WebControls.CheckBoxList checkBoxList)
        {
            var selectedItems = new List <string>();

            for (int i = 0; i < checkBoxList.Items.Count; i++)
            {
                string value = Request.Form[checkBoxList.UniqueID + "$" + i.ToString()];
                if (value != null)
                {
                    checkBoxList.Items[i].Selected = true;
                    selectedItems.Add(value);
                }
                else
                {
                    checkBoxList.Items[i].Selected = false;
                }
            }

            return(selectedItems.AsDelimited(";"));
        }
Пример #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cbl"></param>
        /// <returns>空字符串或者 数字中间用,分隔开</returns>
        public static string GetCheckBoxListValue(System.Web.UI.WebControls.CheckBoxList cbl)
        {
            //取得CheckBoxList选中项的值
            string returnValue = "";

            if (cbl != null)
            {
                foreach (System.Web.UI.WebControls.ListItem item in cbl.Items)
                {
                    if (item.Selected == true)
                    {
                        returnValue += "," + item.Value;
                    }
                }
            }
            if (!string.IsNullOrEmpty(returnValue))
            {
                returnValue = returnValue.Substring(1);
            }
            return(returnValue);
        }
Пример #13
0
        public Int64 UpdateMultpleFromCity(Int64 HeadIdno, System.Web.UI.WebControls.CheckBoxList chklistFromcity)
        {
            Int64 ID = 0;

            try
            {
                using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
                {
                    List <tblFrmCityDetl> objDetls = db.tblFrmCityDetls.Where(pcd => pcd.User_Idno == HeadIdno).ToList();
                    if (objDetls.Count > 0)
                    {
                        foreach (tblFrmCityDetl pcd in objDetls)
                        {
                            db.DeleteObject(pcd);
                            db.SaveChanges();
                        }
                    }
                    for (int i = 0; i < chklistFromcity.Items.Count; i++)
                    {
                        if (chklistFromcity.Items[i].Selected == true)
                        {
                            tblFrmCityDetl obj = new tblFrmCityDetl();
                            obj.User_Idno    = HeadIdno;
                            obj.FrmCity_Idno = Convert.ToInt32(chklistFromcity.Items[i].Value);
                            db.AddTotblFrmCityDetls(obj);
                            db.SaveChanges();
                            ID = obj.FrmCityDetl_Idno;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
            return(ID);
        }
Пример #14
0
        /// <summary>
        /// 填充model
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="control"></param>
        public static void FillModel(Object entity, WebUI.Control control)
        {
            if (entity == null || control == null)
            {
                return;
            }
            NameValueCollection formData = HttpContext.Current.Request.Form;

            PropertyInfo[] propertyList = entity.GetProperties();
            foreach (PropertyInfo pi in propertyList)
            {
                string        ctlId = string.Format(IdFormat, pi.Name);
                WebUI.Control ctl   = control.FindControl(ctlId);
                if (ctl == null)
                {
                    #region 处理HMTL标签
                    if (formData[ctlId] != null)
                    {
                        entity.SetPropertyValue(pi.Name, formData[ctlId]);
                    }
                    #endregion
                    continue;
                }
                Type ctlType = ctl.GetType();

                #region 处理服务器控件
                if (ctlType == typeof(WebUI.WebControls.TextBox))//文本框
                {
                    entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.TextBox)ctl).Text);
                }
                else if (ctlType == typeof(WebUI.WebControls.Image))//图片
                {
                    entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.Image)ctl).ImageUrl);
                }
                else if (ctlType == typeof(WebUI.WebControls.DropDownList))//选择框
                {
                    entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.DropDownList)ctl).SelectedValue);
                }
                else if (ctlType == typeof(WebUI.WebControls.HiddenField))//隐藏域
                {
                    entity.SetPropertyValue(pi.Name, ((WebUI.WebControls.HiddenField)ctl).Value);
                }
                else if (ctlType == typeof(WebUI.WebControls.RadioButton))//单选框
                {
                    WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl;

                    if (rb.Checked)
                    {
                        entity.SetPropertyValue(pi.Name, rb.Text);
                    }
                    else
                    {
                        entity.SetPropertyValue(pi.Name, "");
                    }
                }
                else if (ctlType == typeof(WebUI.WebControls.CheckBox))//复选框
                {
                    WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl;
                    if (ck.Checked)
                    {
                        entity.SetPropertyValue(pi.Name, ck.Text);
                    }
                    else
                    {
                        entity.SetPropertyValue(pi.Name, "");
                    }
                }
                else if (ctlType == typeof(WebUI.WebControls.CheckBoxList))//复选框列表
                {
                    WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl;
                    string rs = "";
                    foreach (WebUI.WebControls.ListItem li in ck.Items)
                    {
                        if (li.Selected)
                        {
                            rs += "," + li.Value;
                        }
                    }
                    if (rs.Length > 1)
                    {
                        rs = rs.Substring(1);
                    }
                    entity.SetPropertyValue(pi.Name, rs);
                }
                else if (ctlType == typeof(WebUI.WebControls.RadioButtonList))//单框列表
                {
                    WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl;
                    entity.SetPropertyValue(pi.Name, ck.SelectedValue);
                }
                else if (ctlType == typeof(WebUI.WebControls.ListBox))//列表框
                {
                    WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl;
                    string rs = "";
                    foreach (WebUI.WebControls.ListItem li in ck.Items)
                    {
                        if (li.Selected)
                        {
                            rs += "," + li.Value;
                        }
                    }
                    if (rs.Length > 1)
                    {
                        rs = rs.Substring(1);
                    }
                    entity.SetPropertyValue(pi.Name, rs);
                }
                #endregion
                #region 处理不同Html控件
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputText))//文本域
                {
                    WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl;
                    entity.SetPropertyValue(pi.Name, ct.Value);
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域
                {
                    WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl;
                    entity.SetPropertyValue(pi.Name, ct.Value);
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlSelect))//选择域
                {
                    WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl;
                    entity.SetPropertyValue(pi.Name, ct.Items[ct.SelectedIndex].Value);
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域
                {
                    WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl;
                    entity.SetPropertyValue(pi.Name, ct.Value);
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域
                {
                    WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl;
                    if (rb.Checked)
                    {
                        entity.SetPropertyValue(pi.Name, rb.Value);
                    }
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域
                {
                    WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl;
                    if (ck.Checked)
                    {
                        entity.SetPropertyValue(pi.Name, ck.Value);
                    }
                }
                else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域
                {
                    WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl;
                    entity.SetPropertyValue(pi.Name, ck.Value);
                }
                #endregion
            }
        }
Пример #15
0
 public void cargarProductos_CheckBoxList(ref System.Web.UI.WebControls.CheckBoxList checkboxlist)
 {
     Controles.LlenarCheckBoxList(ref checkboxlist, pr.ProductosSelectActivos(), "Descripcion", "IdProducto");
 }
Пример #16
0
        /// <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;
        }
Пример #17
0
        /// <summary>
        /// 服务器控件的翻译,从数据库中取值
        /// </summary>
        /// <param name="control">要翻译的控件</param>
        /// <param name="items">二维数组型参数,第二维第一个为字典键值,第二个为默认值</param>
        public void TranControlsDB(object control, string[][] items)
        {
            switch (control.GetType().ToString())       //
            {
            case "System.Web.UI.WebControls.GridView":
                System.Web.UI.WebControls.GridView gv = (System.Web.UI.WebControls.GridView)control;
                Translation.TranslationGridViewDB(gv, items);
                break;

            case "System.Web.UI.WebControls.DataGrid":
                System.Web.UI.WebControls.DataGrid dg = (System.Web.UI.WebControls.DataGrid)control;
                Translation.TranslationDataGridDB(dg, items);
                break;

            case "System.Web.UI.WebControls.RadioButtonList":
                System.Web.UI.WebControls.RadioButtonList rbl = (System.Web.UI.WebControls.RadioButtonList)control;
                Translation.TranslationRadioButtonListDB(rbl, items);
                break;

            case "System.Web.UI.WebControls.DropDownList":
                System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)control;
                Translation.TranslationDropDownListDB(ddl, items);
                break;

            case "System.Web.UI.WebControls.CheckBoxList":
                System.Web.UI.WebControls.CheckBoxList chkl = (System.Web.UI.WebControls.CheckBoxList)control;
                Translation.TranslationCheckBoxListDB(chkl, items);
                break;

            case "System.Web.UI.WebControls.Button":
                System.Web.UI.WebControls.Button button = (System.Web.UI.WebControls.Button)control;
                Translation.TranslationButtonDB(button, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.LinkButton":
                System.Web.UI.WebControls.LinkButton lbtn = (System.Web.UI.WebControls.LinkButton)control;
                Translation.TranslationLinkButtonDB(lbtn, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.ImageButton":
                System.Web.UI.WebControls.ImageButton imgBtn = (System.Web.UI.WebControls.ImageButton)control;
                Translation.TranslationImageButtonDB(imgBtn, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.HyperLink":
                System.Web.UI.WebControls.HyperLink hl = (System.Web.UI.WebControls.HyperLink)control;
                Translation.TranslationHyperLinkDB(hl, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.Label":
                System.Web.UI.WebControls.Label label = (System.Web.UI.WebControls.Label)control;
                Translation.TranslationLabelDB(label, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.CheckBox":
                System.Web.UI.WebControls.CheckBox chk = (System.Web.UI.WebControls.CheckBox)control;
                Translation.TranslationCheckBoxDB(chk, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.RadioButton":
                System.Web.UI.WebControls.RadioButton rbtn = (System.Web.UI.WebControls.RadioButton)control;
                Translation.TranslationRadioButtonDB(rbtn, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.RequiredFieldValidator":
                System.Web.UI.WebControls.RequiredFieldValidator rfv = (System.Web.UI.WebControls.RequiredFieldValidator)control;
                Translation.TranslationRequiredFieldValidatorDB(rfv, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.RangeValidator":
                System.Web.UI.WebControls.RangeValidator rv = (System.Web.UI.WebControls.RangeValidator)control;
                Translation.TranslationRangeValidatorDB(rv, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.CompareValidator":
                System.Web.UI.WebControls.CompareValidator cv = (System.Web.UI.WebControls.CompareValidator)control;
                Translation.TranslationCompareValidatorDB(cv, items[0][0], items[0][1]);
                break;

            case "System.Web.UI.WebControls.RegularExpressionValidator":
                System.Web.UI.WebControls.RegularExpressionValidator rev = (System.Web.UI.WebControls.RegularExpressionValidator)control;
                Translation.TranslationRegularExpressionValidatorDB(rev, items[0][0], items[0][1]);
                break;
            }
        }
Пример #18
0
        /// <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;
            }
        }
Пример #19
0
 /// <summary>
 /// 清理表单
 /// </summary>
 /// <param name="control"></param>
 public static void ClearForm(WebUI.Control control)
 {
     if (control == null)
     {
         return;
     }
     foreach (WebUI.Control ctl in control.Controls)
     {
         Type type = ctl.GetType();
         #region 处理服务器控件
         if (type == typeof(WebUI.WebControls.TextBox))//文本框
         {
             WebUI.WebControls.TextBox box = ((WebUI.WebControls.TextBox)ctl);
             box.Text = "";
             if (box.Attributes["isNumber"] != null)
             {
                 box.Text = "0";
             }
         }
         else if (type == typeof(WebUI.WebControls.DropDownList))//选择框
         {
             ((WebUI.WebControls.DropDownList)ctl).SelectedIndex = -1;
         }
         else if (type == typeof(WebUI.WebControls.HiddenField))//隐藏域
         {
             ((WebUI.WebControls.HiddenField)ctl).Value = "";
         }
         else if (type == typeof(WebUI.WebControls.RadioButton))//单选框
         {
             WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl;
             rb.Checked = false;
         }
         else if (type == typeof(WebUI.WebControls.CheckBox))//复选框
         {
             WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl;
             ck.Checked = false;
         }
         else if (type == typeof(WebUI.WebControls.CheckBoxList))//复选框列表
         {
             WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl;
             foreach (WebUI.WebControls.ListItem li in ck.Items)
             {
                 li.Selected = false;
             }
         }
         else if (type == typeof(WebUI.WebControls.RadioButtonList))//单框列表
         {
             WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl;
             foreach (WebUI.WebControls.ListItem li in ck.Items)
             {
                 li.Selected = false;
             }
         }
         else if (type == typeof(WebUI.WebControls.ListBox))//列表框
         {
             WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl;
             foreach (WebUI.WebControls.ListItem li in ck.Items)
             {
                 li.Selected = false;
             }
         }
         #endregion
         #region 处理不同Html控件
         else if (type == typeof(WebUI.HtmlControls.HtmlInputText))//文本域
         {
             WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl;
             ct.Value = "";
             if (ct.Attributes["isNumber"] != null)
             {
                 ct.Value = "0";
             }
         }
         else if (type == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域
         {
             WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl;
             ct.Value = "";
         }
         else if (type == typeof(WebUI.HtmlControls.HtmlSelect))//选择域
         {
             WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl;
             ct.SelectedIndex = -1;
         }
         else if (type == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域
         {
             WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl;
             ct.Value = "";
             if (ct.Attributes["isNumber"] != null)
             {
                 ct.Value = "0";
             }
         }
         else if (type == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域
         {
             WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl;
             rb.Checked = false;
         }
         else if (type == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域
         {
             WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl;
             ck.Checked = false;
         }
         else if (type == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域
         {
             WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl;
             ck.Value = "";
         }
         #endregion
     }
 }
Пример #20
0
 /// <summary>
 /// 填充表单
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="control"></param>
 public static void FillForm(WebUI.Control control, Object entity)
 {
     if (entity == null || control == null)
     {
         return;
     }
     PropertyInfo[] propertyList = entity.GetProperties();
     foreach (PropertyInfo pi in propertyList)
     {
         WebUI.Control ctl = control.FindControl(string.Format(IdFormat, pi.Name));
         if (ctl == null)
         {
             continue;
         }
         Type ctlType = ctl.GetType();
         #region 处理服务器控件
         if (ctlType == typeof(WebUI.WebControls.TextBox))//文本框
         {
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ((WebUI.WebControls.TextBox)ctl).Text = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.Image))//图片
         {
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 string imageUrl = entity.GetPropertyValue(pi.Name).ToString();
                 if (!string.IsNullOrEmpty(imageUrl))
                 {
                     ((WebUI.WebControls.Image)ctl).ImageUrl = imageUrl;
                 }
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.DropDownList))//选择框
         {
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ((WebUI.WebControls.DropDownList)ctl).SelectedValue = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.HiddenField))//隐藏域
         {
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ((WebUI.WebControls.HiddenField)ctl).Value = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.RadioButton))//单选框
         {
             WebUI.WebControls.RadioButton rb = (WebUI.WebControls.RadioButton)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 rb.Checked = entity.GetPropertyValue(pi.Name).ToString() == rb.Text ? true : false;
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.CheckBox))//复选框
         {
             WebUI.WebControls.CheckBox ck = (WebUI.WebControls.CheckBox)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ck.Checked = entity.GetPropertyValue(pi.Name).ToString() == ck.Text ? true : false;
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.CheckBoxList))//复选框列表
         {
             WebUI.WebControls.CheckBoxList ck = (WebUI.WebControls.CheckBoxList)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 string sel = entity.GetPropertyValue(pi.Name).ToString();
                 foreach (WebUI.WebControls.ListItem li in ck.Items)
                 {
                     if (sel.IndexOf(",") > -1 && (sel.IndexOf(li.Value + ",") > -1 || sel.IndexOf("," + li.Value) > -1))
                     {
                         li.Selected = true;
                     }
                     else if (sel.IndexOf(",") == -1 && sel == li.Value)
                     {
                         li.Selected = true;
                     }
                     else
                     {
                         li.Selected = false;
                     }
                 }
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.RadioButtonList))//单框列表
         {
             WebUI.WebControls.RadioButtonList ck = (WebUI.WebControls.RadioButtonList)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ck.SelectedValue = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.WebControls.ListBox))//列表框
         {
             WebUI.WebControls.ListBox ck = (WebUI.WebControls.ListBox)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 string sel = entity.GetPropertyValue(pi.Name).ToString();
                 foreach (WebUI.WebControls.ListItem li in ck.Items)
                 {
                     if (sel.IndexOf(",") > -1 && (sel.IndexOf(li.Value + ",") > -1 || sel.IndexOf("," + li.Value) > -1))
                     {
                         li.Selected = true;
                     }
                     else if (sel.IndexOf(",") == -1 && sel == li.Value)
                     {
                         li.Selected = true;
                     }
                     else
                     {
                         li.Selected = false;
                     }
                 }
             }
         }
         #endregion
         #region 处理不同Html控件
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputText))//文本域
         {
             WebUI.HtmlControls.HtmlInputText ct = (WebUI.HtmlControls.HtmlInputText)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ct.Value = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlTextArea))//文本域
         {
             WebUI.HtmlControls.HtmlTextArea ct = (WebUI.HtmlControls.HtmlTextArea)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ct.Value = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlSelect))//选择域
         {
             WebUI.HtmlControls.HtmlSelect ct = (WebUI.HtmlControls.HtmlSelect)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 for (int i = 0; i < ct.Items.Count; i++)
                 {
                     if (ct.Items[i].Value == entity.GetPropertyValue(pi.Name).ToString())
                     {
                         ct.SelectedIndex = i;
                     }
                 }
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputHidden))////隐藏域
         {
             WebUI.HtmlControls.HtmlInputHidden ct = (WebUI.HtmlControls.HtmlInputHidden)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ct.Value = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputRadioButton))//单选域
         {
             WebUI.HtmlControls.HtmlInputRadioButton rb = (WebUI.HtmlControls.HtmlInputRadioButton)ctl;
             if (rb.Checked && entity.GetPropertyValue(pi.Name) != null)
             {
                 rb.Checked = entity.GetPropertyValue(pi.Name).ToString() == rb.Value ? true : false;
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputCheckBox))//复选域
         {
             WebUI.HtmlControls.HtmlInputCheckBox ck = (WebUI.HtmlControls.HtmlInputCheckBox)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 if (entity.GetPropertyValue(pi.Name).ToString().IndexOf("," + ck.Value) != -1)
                 {
                     ck.Checked = true;
                 }
             }
         }
         else if (ctlType == typeof(WebUI.HtmlControls.HtmlInputPassword))//密码域
         {
             WebUI.HtmlControls.HtmlInputPassword ck = (WebUI.HtmlControls.HtmlInputPassword)ctl;
             if (entity.GetPropertyValue(pi.Name) != null)
             {
                 ck.Value = entity.GetPropertyValue(pi.Name).ToString();
             }
         }
         #endregion
     }
 }