Friday, July 15, 2016

What is the difference between bool and Boolean types in C#?

bool is an alias for System.Boolean just as int is an alias for System.Int32.
C# Type.NET Framework Type
bool System.Boolean
byte System.Byte
sbyte  System.SByte
char System.Char
decimal System.Decimal
double System.Double
float System.Single
int System.Int32
uint System.UInt32
long System.Int64
ulong System.UInt64
object System.Object
short System.Int16
ushort System.UInt16
string System.String

Folder Permissions on Windows Azure Web Sites

What you can do is change permissions on a local instance of the application and then deploy it with Web Deploy. When you do that, Web Deploy will use the SetAcl operation to change permissions.
SetACL – Automate Permissions and Manage ACLs...
----------------------------------------------------------------------------------------------------------------------

Folder permissions cannot be set/customized. This means whatever location your app writes to should be under your site root.

Monday, July 11, 2016

Difference between single quotes and double quotes in Javascript

You'll want to use single quotes where you want double quotes to appear inside the string (e.g. for html attributes) without having to escape them, or vice versa. Other than that, there is no difference.
I wouldn't say there is a preferred method. You can use either. However, if you are using one form of quote in the string, you might want to use the other as the literal.
alert('Say "Hello"');

alert("Say 'Hello'");

Monday, July 4, 2016

Bootstrap's JavaScript requires jQuery version 1.9.1 or higher

Change the order of files it should be like below..
<script src="js/jquery-1.11.0.min.js"></script>
<script src="js/bootstrap.min.js"></script>

<script src="js/wow.min.js"></script>

Wednesday, June 29, 2016

How to get my project path?

private void btn_upload_Click(object sender, EventArgs e)
        {
            OpenFileDialog op1 = new OpenFileDialog();
            op1.Multiselect = true;
            op1.ShowDialog();
            op1.Filter = "allfiles|*.xls";
            textBox1.Text = op1.FileName;
            int count = 0;
            string[] FName;
            foreach (string s in op1.FileNames)
            {
                //string startupPath1 = System.IO.Directory.GetCurrentDirectory();
                //string startupPath = Environment.CurrentDirectory;
                string wanted_path = Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()));
                FName = s.Split('\\');
                File.Copy(s, wanted_path + "\\Upload\\ " + FName[FName.Length - 1]);
                count++;
            }
            MessageBox.Show(Convert.ToString(count) + " File(s) copied");

        }

Tuesday, June 28, 2016

How can I check ModelState.IsValid from inside my Razor view

@if (!ViewData.ModelState.IsValid)
{
    <div>There are some errors</div>
<script>fun()<script>
}
function fun()
{
}

Sunday, June 26, 2016

InnerException = {"The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value.\r\nThe statement has been terminated."}

This is the case if you have a date time set to 0001-01-01 because it’s out of range for Sql Server (even with Sql Server 2008 R2). In fact, Sql Server date can have date only after the year 1753.

The solution to this problem is to set a property date or to make nullable this field in the database and into your entity. This ways, you could set to null if the date is not set. Otherwise, you can use instead of of 0001-01-01 an other date has a “not set date” which is over 1753-01-01.

Wednesday, June 22, 2016

What's the difference between event.stopPropagation and event.preventDefault?

stopPropagation stops the event from bubbling up the event chain.
preventDefault prevents the default action the browser makes on that event.
Let's say you have
<div id="foo">
 <button id="but" />
</div>

$("#foo").click(function() {
   // mouse click on div
});

$("#but").click(function(ev) {
   // mouse click on button
   ev.stopPropagation();
});

jQuery limit to 2 decimal places

var amount = $("#textid").slider("value") * 1.60;
$("#textboxid2").val('$' + amount.toFixed(2));

Monday, June 20, 2016

Default return type of LINQ Query

If you are querying a database(Linq to SQL) then the return type is IQueryable<T> where T is Product in below example
var product = from p in dbContext.Products
             select p;


If you are using Linq againist a datasource which is an Enumerable collection(List) then the return type will be IEnumerable<t>
------------------------------------------
it depends on your original data source. It can be either IEnumerable or IQueryable 

The result of a Linq database query is typically IQueryable<T> . 

If the database query includes an OrderBy clause, the type is IOrderedQueryable<T> .It is derive from IQueryable<T> 

If the data source is an IEnumerable, the result type is IEnumerable<T> 

You can find out the datatype by calling .GetType() on the source.