public string ToHtmlString() { IHtmlWriter htmlWriter = new HtmlWriter(); this.SetupDataBind(htmlWriter); if (null != this.field.Widget && !String.IsNullOrEmpty(this.field.Widget.Width)) htmlWriter.Prop("style", "width:" + this.field.Widget.Width); //ReadOnly jQuery 1.6+ if (this.field.ReadOnly) htmlWriter.Prop("disabled", true); //setUpValidation htmlWriter .Prop("data-val", "true"); if (!this.field.IsNullable) { htmlWriter .Prop("required", "true") .Prop("data-val-required", "Bu Alan Boş Geçilemez.") .Prop("data-required-required", "Bu Alan Boş Geçilemez."); } // htmlWriter.AppendExtendedHtml(this.field);//tag lenmeden önce this.WriteHtml(htmlWriter, this.field); string html = htmlWriter.ToString(); string script = ""; IHtmlWriter scriptWriter = new HtmlWriter(); this.WriteScript(scriptWriter, this.field); if (scriptWriter.Length > 0) { IHtmlWriter scriptWriterFinal = new HtmlWriter(); scriptWriterFinal .Append("jQuery(function(){") .Append(scriptWriter) .Append("});") .Tag("script", TagTypes.Paired); script = scriptWriterFinal.ToString(); } return html + script; }
public string ToHtmlString() { var writer = new HtmlWriter() .Prop("type", "checkbox") .Prop("id", this.propertyName) .Prop("name", this.propertyName) .Prop("data-bind", "checked:" + this.field.PropertyName); if (this.field.ReadOnly) { writer.Prop("disabled", "true"); } //setUpValidation writer.Prop("data-val", "true"); if (!this.field.IsNullable) { writer .Prop("required", "true") .Prop("data-val-required", "Bu Alan Boş Geçilemez.") .Prop("data-required-required", "Bu Alan Boş Geçilemez."); } // writer.AppendExtendedHtml(this.field);//tag lenmeden önce return writer.Tag("input", TagTypes.Unpaired).ToString(); }