Feb 28, 2018

.NET Core 2.0 SOAP platform not supported error

For developing SOAP / WCF services use:

System.ServiceModel.Http  NUPackage

Use SVCUTIL to generate proxy from WSDL file or url.

If you get error :

PlatformNotSupportedException: Compiling JScript/CSharp scripts is not supported

read this:

https://github.com/dotnet/wcf/issues/2219

Put this before Client method call:

    MethodInfo method = typeof(XmlSerializer).GetMethod("set_Mode", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
    method.Invoke(null, new object[] { 1 });

Feb 15, 2018

Bootstrap Custom Controls

Feb. 2018

Bootstrap Date picker with localization

Only one package required for example Bower or npm:

bootstrap-datepicker 

Reference package and css with appropriate Locale file. Dist folder is here only due to Bower :

    <link rel="stylesheet" href="~/lib/bootstrap-datepicker/dist/css/bootstrap-datepicker.standalone.min.css" />
...

<script src="~/lib/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
 <script src="~/lib/bootstrap-datepicker/dist/locales/bootstrap-datepicker.hr.min.js"></script>

Set language param during init and it should work:

            $('input[name="Birthday2"]').datepicker({
                isRTL: false,
                format: 'dd.mm.yyyy',
                autoclose: true,
                language: 'hr'
            });


Bootstrap Multiselect Checkpoint

https://github.com/davidstutz/bootstrap-multiselect.git

http://davidstutz.de/bootstrap-multiselect/

Apply on existing <select> DOM element.

<script src="~/lib/bootstrap-multiselect/dist/js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="~/lib/bootstrap-multiselect/dist/css/bootstrap-multiselect.css"/>


$(dom.multiselectCss).multiselect();

Feb 6, 2018

ASP.NET MVC - Injecting C# data into Java script

Inside Razor view use Newtonsoft JSON serialization from C# to JSON:

@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(ViewBag.CityList,  Newtonsoft.Json.Formatting.None));