I'm developing a .NET MVC application. In my .cshtml file I have provided a simple calendar tool in one of my textbox as follows :
<input class="form-control" id="createdOn" type="text" />
Here's the JS script for it:
$(document).ready(function ()
{
$("#createdOn").datepicker();
}
Now I want to check whether the user has selected any date in the above metioned text box or not in one of my C# file.
I have a LINQ query which retrieves data and is stored in a variable named "query".
So the code in this C# file goes like this :
var query = ( from //and so on
select {
// data to fetch
}
//below is where I'm stuck
if (!string.IsNullOrEmpty(sc.CreatedOn)) // here sc is an entity
{
query.Where(w => w.CreatedOn == sc.CreatedOn);
}
return query.ToList();
}
So here the above IF Block doesn't seems to validate the CreatedOn properly. What am I doing wrong? Can anyone tell a better way to validate it?