コード例 #1
0
        /// <summary>
        ///     Adds the search fields to the criteria panel
        /// </summary>
        private void InitialiseField(HtmlGenericControl row, Search.SearchParameter parameter, Int32 width)
        {
            BaseInputControl control = null;

            switch (parameter.FieldType)
            {
            case "textbox":
            case "jslookup": control = new TextField(); break;

            case "datepicker": control = new DateField(); break;

            case "checkbox": control = new CheckField(); break;

            case "select": control = this.InitialiseListField(parameter); break;
            }

            // Add the control to the parameter panel
            if (control != null)
            {
                control.ID             = parameter.FieldName;
                control.LabelText      = parameter.CustomLabel.TrimOrNullify() ?? parameter.DefaultLabel;
                control.DataBoundValue = parameter.FieldName;
                control.CssClass      += " col-md-" + width.ToString();
                if (parameter.FieldName == "PN_SURNAME")
                {
                    control.FieldValueRaw = (object)(string.IsNullOrEmpty(PersonSurname) ? "" : PersonSurname);
                }
                row.Controls.Add(control);
            }
        }
コード例 #2
0
        private int validateField(string dataValue, CheckField chkFld)
        {
            int retval = 0;

            if (dataValue.Length > 0)
            {
                // if the expected data type is a string, there's nothing to do
                if (dataValue.GetType() != chkFld.DataType)
                {
                    // special value handling is necessary if the expected data type is a DateTime
                    if (chkFld.DataType == typeof(DateTime))
                    {
                        // try to parse the data value first to guard against known goofy formats
                        DateTime tempDate = Utilities.ParseDate(dataValue);
                        if (tempDate.CompareTo(DateTime.MinValue) != 0)
                        {
                            dataValue = tempDate.ToShortDateString();
                        }
                    }

                    // try to convert the value to the expected data type
                    try
                    {
                        object obj = Convert.ChangeType(dataValue, chkFld.DataType);
                    }
                    catch
                    {
                        string msg = string.Format("File [{0}] is corrupt. The value [{1}], in the field [{2}], at position [{3}], does not match the expected validation data type of [{4}].",
                                                   this.Filename,
                                                   dataValue,
                                                   chkFld.Name,
                                                   chkFld.Index,
                                                   chkFld.DataType.ToString());

                        ValidationErrors.Add(msg);

                        retval = 1;
                    }
                }
            }
            else
            {
                if (chkFld.IsRequired)
                {
                    string msg = string.Format("File [{0}] is corrupt. The field [{1}], at position [{2}], has a \"Data Is Required For Validation\" flag set and there is no field data value.",
                                               this.Filename,
                                               chkFld.Name,
                                               chkFld.Index);

                    ValidationErrors.Add(msg);

                    retval = 1;
                }
            }

            return(retval);
        }
コード例 #3
0
    public static Panel GetEditColumn(string ShowType, Column c, string v)
    {
        if (ShowType == EditShowType.Text.ToString())
        {
            TextField field = new TextField(c, v);

            return(field.Panel);
        }
        else if (ShowType == EditShowType.DateTime.ToString())
        {
            DateTimeField field = new DateTimeField(c, v);
            return(field.Panel);
        }
        else if (ShowType == EditShowType.Check.ToString())
        {
            CheckField field = new CheckField(c, v);
            return(field.Panel);
        }
        else if (ShowType == EditShowType.DropDownList.ToString())
        {
            DropDownField field = new DropDownField(c, v);
            return(field.Panel);
        }
        else if (ShowType == EditShowType.CheckList.ToString())
        {
            CheckListField field = new CheckListField(c, v);
            return(field.Panel);
        }
        else if (ShowType == EditShowType.RadioList.ToString())
        {
            RadioListField field = new RadioListField(c, v);
            return(field.Panel);
        }
        else if (ShowType == EditShowType.picUpload.ToString())
        {
            UploadImgField field = new UploadImgField(c, v);
            return(field.Panel);
        }
        else if (ShowType == EditShowType.MultiText.ToString())
        {
            MultiTextField field = new MultiTextField(c, v);
            return(field.Panel);
        }
        else if (ShowType == EditShowType.Editor.ToString())
        {
            EditorField field = new EditorField(c, v);
            return(field.Panel);
        }
        else if (ShowType == EditShowType.docUpload.ToString())
        {
            UploadFileField field = new UploadFileField(c, v);
            return(field.Panel);
        }
        else if (ShowType == EditShowType.Hidden.ToString())
        {
            Panel       p     = new Panel();
            HiddenField field = new HiddenField();
            field.ID    = c.ColumnName + "_value";
            field.Value = v;
            p.Controls.Add(field);
            return(p);
        }
        else if (ShowType == EditShowType.Template.ToString())
        {
            Page page = HttpContext.Current.Handler as Page;
            if (page != null)
            {
                Control ctrl = page.LoadControl(c.EditTempLate);

                TemplateFields field = new TemplateFields(c, v, ctrl);
                return(field.Panel);
            }
            else
            {
                return(null);
            }
        }
        else
        {
            TextField field = new TextField(c, v);

            return(field.Panel);
        }
    }
コード例 #4
0
ファイル: Form.cs プロジェクト: aicl/Cayita.Javascript
		public static void Execute(Atom parent)
		{
			var form = new Form ();
			new Fieldset (form, fs => {
				new Legend (fs,"Legend");
				new Label(fs, "LabelText");
				new TextInput(fs, i=>{
					i.Placeholder="type something";
					i.Name="text";
				});

				new Span(fs, s=>{s.Text="Example block-level help text here"; s.ClassName="help-block";});

				new CheckField(fs, cf=>{
					cf.Name="allow";
					cf.Input.Text="Check me";
					cf.Input.Checked=true;
				});

				new SubmitButton(fs, b=>{
					b.Text="Send";
					b.Clicked+= (e) =>{ 
						e.PreventDefault();
						form.JQuery.Serialize().LogInfo();
					};
				});
				form.Append(fs);
			});

			parent.JQuery.Append("Default styles".Header (3)).Append (form);

			var sform = new Form ();
			new TextInput (sform, i => {
				i.Name="stext";
				i.Placeholder="search for";
				i.Required=true;
				i.ClassName="input-medium search-query";
				i.MaxLength=8;
				i.MinLength=3;
			});

			new SubmitButton(sform, b=>{
				b.Text="Search...";
				b.Clicked+= (e) =>{ 
					if(!sform.CheckValidity()) return ;
					sform.JQuery.Serialize().LogInfo();
				};
			});

			parent.JQuery.Append("Optional Layouts".Header (3)).Append("Search Form".Header(4)).Append (sform);

			var lform = new Form ();
			lform.SubmitHandler = f =>  f.JQuery.Serialize().LogInfo() ;
			lform.ClassName = "form-inline";
			new EmailInput (lform, i => {
				i.Placeholder = "your email";
				i.Required=true;
				i.Name="email";
			});

			new PasswordInput (lform, i => {
				i.Placeholder = "your password";
				i.Required=true;
				i.Name="password";
				i.MinLength=4;
			});

			new CheckInput (lform,i =>{
				i.Name="remember";
				i.Text="Remember?";
				i.Checked=true;
			});
					
			new SubmitButton (lform, b => b.Text = "submit");
	
			parent.JQuery.Append("Inline Form".Header(4)).Append (lform);

			new Form (f=>{
				f.ClassName="form-horizontal";

				new EmailField(f,i=>{
					i.Text="Email";
					i.Placeholder="your email";
					i.Input.Required=true;
					i.Name="email";
				});

				new PasswordField(f,i=>{
					i.Text="Password";
					i.Placeholder="your password";
					i.Input.Required=true;
					i.Input.MinLength=4;
					i.Name="password";
				});

				new CheckField(f, i=>{
					i.Input.Text="Remember";
					i.Input.Checked=true;
					i.Name="remember";
					new SubmitButton(i.Controls, b=>	b.Text="Login");
				});

				f.SubmitHandler= fr=> fr.JQuery.Serialize().LogInfo();

				parent.JQuery.Append("Horizontal Form".Header(4)).Append (f);
			});


			var login = new Div ("span4 offset3 well");
			login.Append (new Legend("Login Form"));

			new Form (login, f => {
				var nm = new TextField(f);
				nm.Placeholder="user name";
				nm.Name ="username";
				nm.Input.ClassName="span12";
				nm.Input.Required=true;
				nm.Input.MinLength=8;

				var pwd = new PasswordField(f);
				pwd.Placeholder="password";
				pwd.Name ="password";
				pwd.Input.ClassName="span12";
				pwd.Input.Required=true;
				pwd.Input.MinLength=6;
				pwd.Input.MaxLength=10;

				var rmb = new CheckField(f);
				rmb.Name="remember";
				rmb.Input.Text="Remember";

				var sb = new SubmitButton(f);
				sb.Text="Login";
				sb.AddClass("btn-info btn-block");

				f.SubmitHandler= fr=>{
					sb.Disabled=true;
					Window.SetTimeout(()=>{  
						sb.Disabled=false;
						"Welcome {0}".Fmt(nm.Value).LogSuccess();
						f.Reset();
					}, 1000);  
				};

			});

			parent.JQuery.Append ("Samples".Header(3)).Append ("Login Form".Header(4))
				.Append (UI.CreateContainer(ct=> UI.CreateRow(ct, rw=> rw.Append(login))));

			var contact = new Div ("container");
			new Form (contact, f=>{
				f.ClassName="well span8";
				UI.CreateRowFluid(f, row=>{
					new Div(row, p=>{
						p.ClassName="span5";
						new TextField(p, tf=>{tf.Name="firstname"; tf.Required=true; tf.Text="FirstName"; tf.Input.ClassName="span12"; });
						new TextField(p, tf=>{tf.Name="lastname"; tf.Required=true; tf.Text="LastName"; tf.Input.ClassName="span12"; });
						new EmailField(p, tf=>{tf.Name="email"; tf.Required=true; tf.Text="Email";tf.Input.ClassName="span12";});

						new SelectField<string>(p, sf=>{
							sf.Text="Subject";
							sf.Name="subject";
							sf.Input.ClassName="span12";
							sf.Input.Add("", "Choose one...");
							sf.Input.Add("1", "General Customer Service");
							sf.Input.Add("2", "Suggestions");
							sf.Input.Add("3", "Product suport");
							sf.Input.Add("4", "Bug");
							sf.Input.Required=true;
						});

					});
					new Div(row, p=>{
						p.ClassName="span7";
						new TextAreaField(p, tf=>{tf.Name="message"; tf.Rows=11; tf.Text="Message";tf.Input.ClassName="span12";});
					});

					new SubmitButton(row, bt=>{  
						bt.AddClass("btn-primary pull-right");  
						bt.Text="Send";  
					});  
				});

				f.SubmitHandler=fr=> AlertFn.Success(fr.FirstChild,"Message sent",true, 5000);
			});

			parent.JQuery.Append("Conctact Form".Header(4)).Append (contact);

			parent.Append ("C# code".Header(3));

			var rq =jQuery.GetData<string> ("code/demoform.html");
			rq.Done (s=> {
				var code=new Div();
				code.InnerHTML= s;
				parent.Append(code);
			});

		
		}