Monday, November 12, 2018

bootstrap-datepicker sandbox

Just Enjoy Date Piker....

https://uxsolutions.github.io/bootstrap-datepicker/?markup=range&format=&weekStart=&startDate=&endDate=&startView=0&minViewMode=0&maxViewMode=4&todayBtn=false&clearBtn=false&language=en&orientation=auto&multidate=&multidateSeparator=&keyboardNavigation=on&forceParse=on#sandbox

Wednesday, August 8, 2018

Get and Set value into the input fields simultaneously.

HTML:

 <input id="field1" onkeyup="get_set_value_for_field1()" type="text" />
 <input id="field2" onkeyup="get_set_value_for_field2()" type="text" />  

SCRIPT:

 function get_set_value_for_field1() {
            document.getElementById('field2').value = document.getElementById('field1').value;
 }

 function get_set_value_for_field2() {
            document.getElementById('field1').value = document.getElementById('field2').value;
 }

Wednesday, January 10, 2018

Sending email in .NET through Gmail

C# Code Is: 

 var fromAddress = new MailAddress("unbroken4420@gmail.com", "Zihadul");
              var toAddress = new MailAddress("rajon5000@gmail.com", "Rajon");
              const string fromPassword = "*******";
              const string subject = "Subject";
              const string body = "Body";

              var smtp = new SmtpClient
              {
                  Host = "smtp.gmail.com",
                  Port = 587,
                  EnableSsl = true,
                  DeliveryMethod = SmtpDeliveryMethod.Network,
                  UseDefaultCredentials = false,
                  Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
              };
              using (var message = new MailMessage(fromAddress, toAddress)
              {
                  Subject = subject,
                  Body = body
              })
              {
                  smtp.Send(message);
              }

Saturday, January 6, 2018

Base URL For Sub-domain Folder

Set on Muster Page or Layout page:

 <div id="BaseUrl" data-baseurl="@Context.Request.Url.GetLeftPart(UriPartial.Authority)@Url.Content("~/")"></div>   

JS:
var rootFolder = $("#BaseUrl").data("baseurl");
        var route =rootFolder+'/api/ApplicationMenu/Get';

Enabling session state in Web API

Create two classes; SessionControllerHandler and SessionHttpControllerRouteHandler. Implement as follows:

public class SessionControllerHandler : HttpControllerHandler, IRequiresSessionState
{
    public SessionControllerHandler(RouteData routeData)
        : base(routeData)
    { }
}
 
public class SessionHttpControllerRouteHandler : HttpControllerRouteHandler
{
    protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        return new SessionControllerHandler(requestContext.RouteData);
    }
}


In your WebApiConfig, add the following above your route declaration(s):
public static class WebApiConfig { public static void Register(HttpConfiguration config) { // Web API configuration and services var httpControllerRouteHandler = typeof(HttpControllerRouteHandler).GetField("_instance", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic); if (httpControllerRouteHandler != null) { httpControllerRouteHandler.SetValue(null, new Lazy<HttpControllerRouteHandler>(() => new SessionHttpControllerRouteHandler(), true)); } // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); } }


Now Session is On

HttpContext.Current.Session["ForLeftMenu"] = "Rajon";
if (HttpContext.Current.Session["ForLeftMenu"] != null)
{
  string text = HttpContext.Current.Session["ForLeftMenu"].ToString();
            } 


Tuesday, January 2, 2018

Setup dotLess CSS In ASP.NET MVC Project (Minify js/cs file)

Improve performance for dotLess files in MVC projectBundles are an easy way to merge and minify resources in your application (such as JavaScript files and CSS stylesheets). Using “System.Web.Optimization.Less” plugin, you can improve site performance in a better way.

So go back to Package Manager Console and install the below plugin:

PM> Install-Package System.Web.Optimization.Less

And add your bundle to the appropriate location within BundleConfig.cs,
  1. public class BundleConfig  
  2. {  
  3.     public static void RegisterBundles(BundleCollection bundles)  
  4.     {  
  5.         // NOTE: existing bundles are here  
  6.   
  7.         bundles.Add(new LessBundle("~/Content/less").Include("~/Content/*.less"));  
  8.     }  
  9. }  
So, this LessBundle gives you the facility to combine and minify files while running the application in <compilation debug="false" /> mode, and it takes care of transforming LESS code into CSS. It does not require updating the layout every time you add a new file to the project.