I\'ve been using jQuery templates which I absolutely love to use. The only drawback from an IDE standpoint is the lack of HTML IntelliSense inside the script tag. Is there
I'd solved this issue by creating simple custom serverside control (for ASP.NET 4 WebForms app.):
[ToolboxData("<{0}:JqueryTemplate runat=server>{0}:JqueryTemplate>")]
[PersistChildren(true)]
[ParseChildren(false)]
public class JqueryTemplate : Control {
private bool _useDefaultClientIdMode = true;
[DefaultValue(ClientIDMode.Static)]
[Category("Behavior")]
[Themeable(false)]
public override ClientIDMode ClientIDMode {
get {
return (_useDefaultClientIdMode) ? ClientIDMode.Static : base.ClientIDMode;
}
set {
base.ClientIDMode = value;
_useDefaultClientIdMode = false;
}
}
protected override void Render(HtmlTextWriter writer) {
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/x-jquery-tmpl");
writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
writer.RenderBeginTag(HtmlTextWriterTag.Script);
base.Render(writer);
writer.RenderEndTag();
}
}
and put each jquery template inside it (instead of tag):
... your template code goes here ...
will rendered it in HTML as: