SqlImage extension methods

In your views you can use Html extension methods to render <img />, <input type="image" /> html elements. Actually the methods give you back HtmlString containing the html element. These elements src attributes target MVC actinons. Those actions use the url parameters and configuration settings to render images and write the generated images back to the response stream. There is an Url extension method to get back only the url instead of the full html tag.
All three types of extension methods have overloads with different parameters. The first parameter is always the key that points to a config entry.

The key parameter must be an existing key in the Tacepao config settings.
The image and rotation parameters are exactly the same as in the configuration settings.
The text parameter gives text to the image. This text will be used on the rendered image. This is the only way to give text to SqlImage (you can not give this attribute in the config file).
The sqlParameters parameter should be an anonymous object. This is used if the referenced Tacepao (with the first key parameter) has the command attribute filled. Then this anonymous object's properties will be used as the parameters of that command.
The htmlAttributes is the same parameter as anywhere in MVC. It applies html attributes to the rendered html tag.
There always is an extension method with controller and action parameters. This overload can be used if you do not want to use the default XAMLtoMVC actions.
Below you can find the list of all Tacepao extensions methods.

Extension methods to render <img />

Html.SqlImage(string key, object sqlParameters)
Html.SqlImage(string key, string text, string image)
Html.SqlImage(string key, string image, object sqlParameters, object htmlAttributes)
Html.SqlImage(string key, string image, double rotation, object sqlParameters, object htmlAttributes)
Html.SqlImage(string key, string text, string image, double? rotation, object sqlParameters, object htmlAttributes)
Html.SqlImage(string controller, string action, string key, string text, string image, double? rotation, object sqlParameters, object htmlAttributes)

Extension methods to render <input type="image" />

Html.SqlImageInput(string key, object sqlParameters)
Html.SqlImageInput(string key, string text, string image)
Html.SqlImageInput(string key, string image, object sqlParameters, object htmlAttributes)
Html.SqlImageInput(string key, string image, double rotation, object sqlParameters, object htmlAttributes)
Html.SqlImageInput(string key, string text, string image, double? rotation, object sqlParameters, object htmlAttributes)
Html.SqlImageInput(string controller, string action, string key, string text, string image, double? rotation, object sqlParameters, object htmlAttributes)

Extension methods to get Url to an action that renders an image

Url.SqlImageUrl(string key, object sqlParameters)
Url.SqlImageUrl(string key, string image, object sqlParameters)
Url.SqlImageUrl(string key,  string image, double rotation, object sqlParameters)
Url.SqlImageUrl(string key, string text, string image, double? rotation, object sqlParameters)
Url.SqlImageUrl(string controller, string action, string key, string text, string image, double? rotation, object sqlParameters)

Last edited Feb 28, 2011 at 12:09 AM by Tocsi, version 9

Comments

No comments yet.