)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » HtmlHelper (Ia.Cl.Model)

Public general use code classes and xml files that we've compiled and used over the years:

HtmlHelper for ASP.Net Core.

    1: using System;
    2: using System.IO;
    3: using Microsoft.AspNetCore.Html;
    4: using Microsoft.AspNetCore.Mvc.Rendering;
    5: using Microsoft.Extensions.Configuration;
    6:  
    7: namespace Ia.Cl.Model
    8: {
    9:     ////////////////////////////////////////////////////////////////////////////
   10:  
   11:     /// <summary publish="true">
   12:     /// HtmlHelper for ASP.Net Core.
   13:     /// </summary>
   14:     /// <remarks> 
   15:     /// Copyright © 2023-2024 Jasem Y. Al-Shamlan (info@ia.com.kw), Integrated Applications - Kuwait. All Rights Reserved.
   16:     ///
   17:     /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
   18:     /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
   19:     ///
   20:     /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
   21:     /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
   22:     /// 
   23:     /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
   24:     /// 
   25:     /// Copyright notice: This notice may not be removed or altered from any source distribution.
   26:     /// </remarks> 
   27:     public static class HtmlHelper
   28:     {
   29:         /*
   30: _ViewImports.cshtml (second line is the important change):
   31: 
   32: @using Ia.Cl.Models.HtmlHelper
   33: @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
   34: 
   35: *.cshtml:
   36: 
   37: <div>@Html.GridView()</div>         
   38:         */
   39:  
   40:         private static IConfigurationRoot _configuration;
   41:  
   42:         ////////////////////////////////////////////////////////////////////////////
   43:  
   44:         /// <summary>
   45:         ///
   46:         /// </summary>
   47:         public static IHtmlContent GridView(this IHtmlHelper htmlHelper)
   48:         {
   49:             return new HtmlString(" < strong>GridView</strong>");
   50:         }
   51:  
   52:         ////////////////////////////////////////////////////////////////////////////
   53:  
   54:         /// <summary>
   55:         ///
   56:         /// </summary>
   57:         public static IHtmlContent HelloWorld(this IHtmlHelper html, string name)
   58:         {
   59:             var span = new TagBuilder("span");
   60:             span.InnerHtml.Append("Hello, " + name + "!");
   61:  
   62:             var br = new TagBuilder("br") { TagRenderMode = TagRenderMode.SelfClosing };
   63:  
   64:             string result;
   65:  
   66:             using (var writer = new StringWriter())
   67:             {
   68:                 span.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default);
   69:                 br.WriteTo(writer, System.Text.Encodings.Web.HtmlEncoder.Default);
   70:                 result = writer.ToString();
   71:             }
   72:  
   73:             return new HtmlString(result);
   74:         }
   75:  
   76:         ////////////////////////////////////////////////////////////////////////////
   77:  
   78:         /// <summary>
   79:         ///
   80:         /// </summary>
   81:         public static IHtmlContent SubmitButton(this IHtmlHelper htmlHelper, string value, string name)
   82:         {
   83:             string str = "<input type='submit' value ='" + value + "'name='" + name + "' />";
   84:             return new HtmlString(str);
   85:         }
   86:  
   87:         ////////////////////////////////////////////////////////////////////////////
   88:         ////////////////////////////////////////////////////////////////////////////
   89:     }
   90:  
   91:     ////////////////////////////////////////////////////////////////////////////
   92:     ////////////////////////////////////////////////////////////////////////////
   93: }