Skip to content

alimon808/TagHelpers

 
 

Repository files navigation

LazZiya.TagHelpers

Collection of helpful TagHelpers for any ASP.NET Core project.

Latest release

13 January 2020

  • v3.1.2
  • PagingTagHelper
    • Hotfix for issue #8
    • Deprected: "PageSizeNavFormMethod" property is no more required, will be removed in a feature release
    • "Items per page" renamed to "Page size"

Notice

Starting from v3.1.0 all opitons are on by default, can be turned off manually if not needed. See Demo page for more details about all options.

Contents

Installation:

Install via nuget :

Install-Package LazZiya.TagHelpers

add tag helper to _ViewImports.cshtml:

@addTagHelper *, LazZiya.TagHelpers

Code Samples

Paging TagHelper

Only few parameters are required to fireup the agination control

  • version >= 3.1.0
<paging total-records="Model.TotalRecords"
        page-no="Model.PageNo">
</paging>
  • version <= 3.0.2
<paging total-records="Model.TotalRecords"
        page-no="Model.PageNo"
        query-string-value="@(Request.QueryString.Value)">
</paging>

it is important to add query-string-value for versions before 3.1.0.

For more details :

Localize TagHelper

Use simple html tag to localize text/html in razor views

<localize>Hellow world!</localize>

Requires LazZiya.TagHelpers.Localization and LazZiya.ExpressLocalization nuget packages.

Read more:

Alert TagHelper

Easily create bootstrap 4.x alerts from c# backend or razor pages using html codes. All bootstrap alerts can be created from both ends (Primary, Secondary, Success, Info, Warning, Danger, Light, Dark).

Create alert from razor page using HTML

<alert-success>Congratulations! you have done the job!</alert-success>

Create alert from c# backend

Alert are TempData items, so they will be disposed once they are fetched. You can create alerts from the c# backend by the provided extension methods for TempData as below:

using LazZiya.TagHelpers.Alerts

TempData.Danger("Ooopps! something went wrong with the code, please contact support.");

Then use alert tag helepr on razor side to render the alerts:

  • version >= 3.0.1
<alert></alert>
  • version <= 3.0.0
<alert view-context="ViewContext"></alert>

Read more :

LangaugeNav TagHelper

  • version >= 3.0.1
<language-nav></language-nav>
  • version <= 3.0.0
<language-nav view-context="ViewContext"></language-nav>

For more details :

LocalizationValidationScripts TagHelper

will add all required js files and code to validate localized input fields like numbers, date and currency. These scripts will help to validate localized decimal numbers with comma or dot format (e.g. EN culture: 1.2 - TR culture: 1,2).

1- Register tag helper component in startup. Don't apply this step if you are using ExpressLocalization it will be done automatically

services.AddTransient<ITagHelperComponent, LocalizationValidationScriptsTagHelperComponent>()

2- Add this code to the scripts section in the page:

<localization-validation-scripts></localization-validation-scripts>

For more details :

SelectEnum TagHelper

Sample enum :

public enum WeekDays { MON, TUE, WED, THU, FRI, SAT, SUN }

create the related select list dropdown in razor page :

<select-enum 
        enum-type="typeof(WeekDays)" 
        name="weekDay">
</select-enum>

For more details :

Project site:

http://ziyad.info/en/articles/27-LazZiya_TagHelpers

Live Demos :

http://demo.ziyad.info/en/

License

https://github.com/LazZiya/TagHelpers/blob/master/LICENSE

About

Helpful TagHelpers for any ASP.NET Core project (Paging, Select-Enum, etc).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 94.8%
  • HTML 5.2%