public KnockoutTagBuilder <TModel> HyperlinkButton(string caption, string actionName, string controllerName, object routeValues = null, object htmlAttributes = null) { var tagBuilder = new KnockoutTagBuilder <TModel>(Context, "a", InstanceNames, Aliases); tagBuilder.ApplyAttributes(htmlAttributes); tagBuilder.ApplyAttributes(new { href = "#" }); tagBuilder.Click(actionName, controllerName, routeValues); tagBuilder.SetInnerHtml(HttpUtility.HtmlEncode(caption)); return(tagBuilder); }
public KnockoutTagBuilder <TModel> DropDownList <TItem>(Expression <Func <TModel, IList <TItem> > > options, object htmlAttributes, Expression <Func <TModel, TItem, object> > optionsText) { var tagBuilder = new KnockoutTagBuilder <TModel>(Context, "select", InstanceNames, Aliases); tagBuilder.ApplyAttributes(htmlAttributes); if (options != null) { tagBuilder.Options(Expression.Lambda <Func <TModel, IEnumerable> >(options.Body, options.Parameters)); } if (optionsText != null) { var data = CreateData(); var keys = data.Aliases.Keys.ToList(); if (!string.IsNullOrEmpty(Context.GetInstanceName())) { foreach (var key in keys) { data.Aliases[Context.GetInstanceName() + "." + key] = data.Aliases[key]; data.Aliases.Remove(key); } } data.InstanceNames = new[] { Context.GetInstanceName(), "item" }; tagBuilder.OptionsText("function(item) { return " + KnockoutExpressionConverter.Convert(optionsText, data) + "; }"); } return(tagBuilder); }
private KnockoutTagBuilder <TModel> Input(Expression <Func <TModel, object> > text, string type, object htmlAttributes = null) { var tagBuilder = new KnockoutTagBuilder <TModel>(Context, "input", InstanceNames, Aliases); tagBuilder.ApplyAttributes(htmlAttributes); if (!string.IsNullOrWhiteSpace(type)) { tagBuilder.ApplyAttributes(new { type }); } if (text != null) { tagBuilder.Value(text); } tagBuilder.TagRenderMode = TagRenderMode.SelfClosing; return(tagBuilder); }
public KnockoutTagBuilder <TModel> TextArea(Expression <Func <TModel, object> > text, object htmlAttributes = null) { var tagBuilder = new KnockoutTagBuilder <TModel>(Context, "textarea", InstanceNames, Aliases); tagBuilder.ApplyAttributes(htmlAttributes); tagBuilder.Value(text); return(tagBuilder); }
public KnockoutTagBuilder <TModel> SpanInline(string text, object htmlAttributes = null) { var tagBuilder = new KnockoutTagBuilder <TModel>(Context, "span", InstanceNames, Aliases); tagBuilder.ApplyAttributes(htmlAttributes); tagBuilder.Text(text); return(tagBuilder); }
public KnockoutTagBuilder <TModel> Span(string text, object htmlAttributes = null) { var tagBuilder = new KnockoutTagBuilder <TModel>(Context, "span", InstanceNames, Aliases); tagBuilder.ApplyAttributes(htmlAttributes); tagBuilder.SetInnerHtml(HttpUtility.HtmlEncode(text)); return(tagBuilder); }
public override void WriteStart(TextWriter writer) { var tagBuilder = new KnockoutTagBuilder <TModel>(context, "form", instanceNames, aliases); tagBuilder.ApplyAttributes(htmlAttributes); tagBuilder.Submit(actionName, controllerName, routeValues); tagBuilder.TagRenderMode = TagRenderMode.StartTag; writer.WriteLine(tagBuilder.ToHtmlString()); }
public KnockoutTagBuilder <TModel> DropDownList <TItem>(Expression <Func <TModel, IList <TItem> > > options, object htmlAttributes = null, Expression <Func <TItem, object> > optionsText = null) { var tagBuilder = new KnockoutTagBuilder <TModel>(Context, "select", InstanceNames, Aliases); tagBuilder.ApplyAttributes(htmlAttributes); if (options != null) { tagBuilder.Options(Expression.Lambda <Func <TModel, IEnumerable> >(options.Body, options.Parameters)); } if (optionsText != null) { var data = new KnockoutExpressionData { InstanceNames = new[] { "item" } }; tagBuilder.OptionsText("function(item) { return " + KnockoutExpressionConverter.Convert(optionsText, data) + "; }"); } return(tagBuilder); }
public KnockoutTagBuilder <TModel> DropDownList <TItem>(Expression <Func <TModel, IList <TItem> > > options, object htmlAttributes = null, string optionsTextValue = null, string optionsIdValue = null) { var tagBuilder = new KnockoutTagBuilder <TModel>(Context, "select", InstanceNames, Aliases); tagBuilder.ApplyAttributes(htmlAttributes); if (options != null) { tagBuilder.Options(Expression.Lambda <Func <TModel, IEnumerable> >(options.Body, options.Parameters)); } if (!string.IsNullOrEmpty(optionsTextValue)) { tagBuilder.OptionsText(optionsTextValue, true); } if (!string.IsNullOrEmpty(optionsIdValue)) { tagBuilder.OptionsValue(optionsIdValue, true); } return(tagBuilder); }