13 Ocak 2023 Cuma

Get selected values in a multi-select drop-down with JavaScript

 var hexvalues = [];

var labelvalues = [];

$('#myMultiSelect :selected').each(function(i, selectedElement) {
 hexvalues[i] = $(selectedElement).val();
 labelvalues[i] = $(selectedElement).text();
});

Get selected get customer attribute drop-down with JavaScript

 

<select id="location">
    <option value="a" myTag="123">My option</option>
    <option value="b" myTag="456">My other option</option>
</select>

alert($('#location').find('option:selected').attr('myTag'));


2 Şubat 2022 Çarşamba

c# Number Decimal Separator

     

Tutar işlemlerinde sistem ondalık ayracı farklılıklarından kaynaklanan sorunların önüne geçmek için 

Uygulamanın çalıştığı sunucu/pc üzerinde tanımlı ayracı bilgisini dönen; "CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator" kullanarak daha kısa kod yazabilirsiniz.

Örnek;

string transactionAmount = "1,20"; 

string uiSep = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;

 string Amount = string.Empty;

var x = transactionAmount.Split(uiSep);

 if (x.Length == 2) {

    Amount = x[0] + x[1].PadRight(2,'0');

 } else {

    Amount = x[0] + "00";

}

30 Ocak 2022 Pazar

Javascript Ayın son günü

ayın son günü bulmak için kullanılabilecek bir metot


 function daysInMonth(m, y){

  return m===2?y&3||!(y%25)&&y&15?28:29:30+(m+(m>>3)&1);
}
<!-- example -->
<input type="text" placeholder="enter year" onblur="
  for( var r='', i=0, y=+this.value
     ; 12>i++
     ; r+= 'Month: ' + i + ' has ' + daysInMonth(i, y) + ' days<br>'
     );
  this.nextSibling.innerHTML=r;
" /><div></div>

İşlem tarihinden bir gün sonrasını set ededen metot içinde kullanımı
function formatDate() {
    var d = new Date(),
        month = '' + (d.getMonth() + 1),
        day = '' + (d.getDate() + 1),
        year = d.getFullYear();

    if (month.length < 2)
        month = '0' + month;
    if (day.length < 2)
        day = '0' + day;

// ayın son gününden büyük ise gün set eder
    if (day > daysInMonth(d.getMonth(), year)) 
        day = d.getDate();
    

    return [day, month, year].join('.');
}

19 Ağustos 2021 Perşembe

Windows Servis Projesi Oluşturma

 Consol Projesi oluşturarak aşağıdaki kodlar ile windows servis üzerinden çalışan consol uygulaması geliştirebilirsiniz.

static void Main(string[] args)

        {

            try

            {

                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("tr");

                if (!Environment.UserInteractive)

                    Directory.SetCurrentDirectory(Program.GetServicePath());

                else

                    Directory.SetCurrentDirectory(Program.GetProcessPath());

                if (!Environment.UserInteractive)

                {

                    // running as service

                    using (var service = new Service())

                        ServiceBase.Run(service);

                }

                else

                {

                    // running as console app

                    Start(args);

                    Console.WriteLine("Press any key to stop...");

                    Console.ReadKey(true);

                    Stop();

                }

            }

            catch (Exception ex)

            {

                log.Error(MethodBase.GetCurrentMethod().Name + " - " + ex.Message);

            }

        }

 public static void Start(string[] args)

        {

            try

            {

                var config = new HttpSelfHostConfiguration("http://localhost:8082");

                config.MapHttpAttributeRoutes();

                config.MessageHandlers.Add(new CustomHeaderHandler());

                var server = new HttpSelfHostServer(config);

                server.OpenAsync().Wait();

                log.Info("Server started....");

                ServisHelpers.getSetting();

            }

            catch (Exception ex)

            {

                log.Error(MethodBase.GetCurrentMethod().Name + " - " + ex.Message);

            }

        }


        public static void Stop()

        {


            // onstop code here

        } 

CSS ile INPUT Focuslandığında border renk degişimi

 

CSS ile Input Focus border bilgilerinin degiştirilmesi

.no-focusborder:focus {

    outline-style: none;

    box-shadow: none;

    border-color: deepskyblue;

}