Friday, December 28, 2018

Process with an ID #### is not running in visual studio professional 2013 update 3

Soln 1:-

The following steps fix the problem for Visual Studio 2015 and Visual Studio 2017:

Close VS.
Navigate to the folder of the solution and delete the hidden .vs folder.
Restart VS.
Hit F5 and IIS Express should load as normal, allowing you to debug.



Soln 2:-
Open Visual Studio as an administrator
Right-click your project and click on 'Unload Project'
Again, right-click your project and click on 'Edit PROJECT_NAME.csproj'
Find the code below and delete it:

<DevelopmentServerPort>63366</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:63366/</IISUrl>
Save and close the file .csproj


Thursday, December 20, 2018

Validate that end date is greater than start date with jQuery

var startDate = new Date($('#startDate').val());
var endDate = new Date($('#endDate').val());

if (startDate < endDate){
// Do something
}

Wednesday, December 19, 2018

Jquery & Javascript

What is JQuery?
Well, JQuery is a framework (tools) for writing JavaScript, Written as "write less, do more", jQuery is to make easier to use JavaScript.

What is JavaScript?
JavaScript is an object-oriented computer programming (Scripting) language commonly used to create interactive effects within web browsers.

Ajax:
AJAX stands for “Asynchronous JavaScript and XML”. AJAX is about exchanging data with a server, without reloading the whole page. It is a technique for creating fast and dynamic web pages.

In .NET, we can call server side code using two ways:
        1.ASP .NET AJAX
        2. jQuery AJAX
$.ajax () Method:
JQuery’s core method for creating Ajax requests. Here are some jQuery AJAX methods:
  • $.ajax() Performs an async AJAX request.
  • $.get() Loads data from a server using an AJAX HTTP GET request.
  • $.post() Loads data from a server using an AJAX HTTP POST request
$.ajax () Method Configuration option:
Options that we use:
  • async:
  • type:
  • url:
  • data:
  • datatype:
  • success:
  • error:
async
Set to false if the request should be sent synchronously. Defaults to true. 

Note that if you set this option to false, your request will block execution of other code until the response is received.

syntax: async: false

NonAction method in MVC

NonAction attribute but then the method is still invokable as action method


By default, the MVC framework treats all public methods of a controller class as action methods. If your controller class contains a public method and you do not want it to be an action method, you must mark that method with the NonActionAttribute attribute.

public interface IEmployee
{
 void Save(Employee e);
 bool Validate(Employee e);
}

public class EmployeeController:Controller, IEmployee
{
  public void Save(Employee e){
  }

  [NonAction]
  public void Validate(Employee e){
  }
}

CASE in WHERE, SQL Server

-- Do the comparison, OR'd with a check on the @Country=0 case
WHERE (a.Country = @Country OR @Country = 0)

-- compare the Country field to itself
WHERE a.Country = CASE WHEN @Country > 0 THEN @Country ELSE a.Country END

Sunday, December 2, 2018

Concatenate two column values in LinQ Lambda Expression

Using Take(1) which means you're still getting an IEnumerable<string> or an IQueryable<string>. Just use First() (or possibly FirstOrDefault()) instead of Take(1) and you can drop the ToString() call as well.

string productName = (from P in DataModel.Product
                      join M in DataModel.ProductPackUnit
                        on P.PUNIT_ID equals M.ID
                      where P.PRODUCT_ID == ProdictId
                      select P.PRODUCT_NAME + " " + P.WEIGHT + " "+ M.UNIT)
                     .FirstOrDefault();

That will only work if your LINQ provider supports the string concatenation operation. An alternative is to fetch just the columns you want, and then concatenate at the caller:

var query = from P in DataModel.Product
            join M in DataModel.ProductPackUnit
              on P.PUNIT_ID equals M.ID
            where P.PRODUCT_ID == ProdictId
            select new { P.PRODUCT_NAME, P.WEIGHT, M.UNIT };

var result = query.FirstOrDefault();
if (result != null)
{
    string productName = result.PRODUCT_NAME + " " +
                         result.WEIGHT + " " +
                         result.UNIT;
    // Use the name
}
else
{
    // No results
}