Exemplo n.º 1
0
        //保存配置的值
        void IFieldEditor.OnSaveChange(SPField field, bool isNewField)
        {
            this.EnsureChildControls();
            if (field != null)
            {
                SPLegalAmountField CuserField = (SPLegalAmountField)field;

                CuserField.SPLegalAmountFieldRelevanceListField = DrRelevanceListField.SelectedValue;
                CuserField.SPLegalAmountFieldTextboxWidth       = txtTextboxWidth.Text;
            }
        }
Exemplo n.º 2
0
 //编辑字段配置信息绑定到控件上
 void IFieldEditor.InitializeWithField(SPField field)
 {
     if (!Page.IsPostBack)
     {
         this.EnsureChildControls();
         BindSPListFieldData(SPContext.Current.ListId, DrRelevanceListField);
     }
     if (!Page.IsPostBack && field != null)
     {
         SPLegalAmountField fields = (SPLegalAmountField)field;
         this.DrRelevanceListField.SelectedValue = fields.SPLegalAmountFieldRelevanceListField;
         this.txtTextboxWidth.Text = fields.SPLegalAmountFieldTextboxWidth;
     }
 }
        protected override void CreateChildControls()
        {
            if (Field == null)
            {
                return;
            }

            if (this.ControlMode == SPControlMode.Display)
            {
                this.TemplateName = this.DisplayTemplateName;
            }
            base.CreateChildControls();
            if (ControlMode == SPControlMode.Display)
            {
                LabSPLegalAmountField = (Label)TemplateContainer.FindControl("LabSPLegalAmountField");
                if (LabSPLegalAmountField == null)
                {
                    throw new ArgumentException("未找到LabSPLegalAmountField控件");
                }
                LabhidSPLegalAmountField = (HiddenField)TemplateContainer.FindControl("LabhidSPLegalAmountField");
                if (LabhidSPLegalAmountField == null)
                {
                    throw new ArgumentException("未找到LabhidSPLegalAmountField控件");
                }


                SPLegalAmountFieldValue fieldValue = (SPLegalAmountFieldValue)this.ItemFieldValue;
                if (fieldValue != null)
                {
                    LabSPLegalAmountField.Text     = fieldValue.AmountCapital;
                    LabhidSPLegalAmountField.Value = fieldValue.AmountNumber;
                }
            }
            else
            {
                txtSPLegalAmountField        = (TextBox)TemplateContainer.FindControl("txtSPLegalAmountField");
                hidSPLegalAmountField        = (HiddenField)TemplateContainer.FindControl("hidSPLegalAmountField");
                hidSPLegalAmountFieldPropery = (HiddenField)TemplateContainer.FindControl("hidSPLegalAmountFieldPropery");

                if (txtSPLegalAmountField == null)
                {
                    throw new ArgumentException("未找到txtSPLegalAmountField控件");
                }
                if (hidSPLegalAmountField == null)
                {
                    throw new ArgumentException("未找到hidSPLegalAmountField控件");
                }
                if (hidSPLegalAmountFieldPropery == null)
                {
                    throw new ArgumentException("未找到hidSPLegalAmountFieldPropery控件");
                }


                SPLegalAmountField field = (SPLegalAmountField)base.Field;
                if (!string.IsNullOrEmpty(field.SPLegalAmountFieldTextboxWidth))
                {
                    txtSPLegalAmountField.Width = Convert.ToInt32(field.SPLegalAmountFieldTextboxWidth.Trim());
                }


                FormField txtAmountLower = GetCurrentFormFieldControl((Control)this.Page, field.SPLegalAmountFieldRelevanceListField);

                if (txtAmountLower != null)
                {
                    string _txtAmountLowerId = txtAmountLower.ClientID + txtAmountLower.ClientID.Replace(txtAmountLower.ClientID, "") + "_TextField";


                    StringBuilder jsstr = new StringBuilder();
                    jsstr.AppendLine("<script type=\"text/javascript\">");
                    jsstr.AppendLine("function convertAmount" + _txtAmountLowerId + "(){");
                    jsstr.AppendLine("var _this=document.getElementById('" + _txtAmountLowerId + "');");
                    jsstr.AppendLine("var _amountlegal = convert(_this.value,_this);");
                    jsstr.AppendLine("document.getElementById('" + txtSPLegalAmountField.ClientID + "').value = _amountlegal;");
                    jsstr.AppendLine("document.getElementById('" + hidSPLegalAmountField.ClientID + "').value = _this.value;");
                    jsstr.AppendLine("}");
                    jsstr.AppendLine("if(/msie/i.test(navigator.userAgent)){");
                    jsstr.AppendLine("document.getElementById('" + _txtAmountLowerId + "').onpropertychange = convertAmount" + _txtAmountLowerId + "");
                    jsstr.AppendLine("}");
                    jsstr.AppendLine("else");
                    jsstr.AppendLine("{");
                    jsstr.AppendLine("document.getElementById('" + _txtAmountLowerId + "').addEventListener(\"input\",convertAmount" + _txtAmountLowerId + ",false);");
                    jsstr.AppendLine("}");
                    jsstr.AppendLine("convertAmount" + _txtAmountLowerId + "();");
                    jsstr.AppendLine("</script>");

                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "Amountchangejs" + field.SPLegalAmountFieldRelevanceListField, jsstr.ToString());
                }
            }
        }