Skip to main content

Posts

Remove HTML tags from string including   in C#

        public static string RemoveHTML(string html)         {             try             {                 StringCollection sc = new StringCollection();                 // get rid of unnecessary tag spans (comments and title)                 sc.Add(@"<!--(\w|\W)+?-->");                 sc.Add(@"<title>(\w|\W)+?</title>");                 // Get rid of classes and styles                 sc.Add(@"\s?class=\w+");                 sc.Add(@"\s+style='[^']+'");                 // Get rid of unnecessary tags            ...

Validate Between Two Times - C#

How to check if DateTime.Now is between two given DateTimes for time part only? Since you are only gathering two times without dates, you need to figure out if the two times are from the same day or not. If you put the   StartTime ,   EndTime , and   Now   into   TimeSpans : If ( StartTime > EndTime ) { // the range crosses midnight, do the comparisons independently Return ( StartTime < Now ) || ( Now < EndTime ); } Else { // the range is on the same day, both comparisons must be true Return StartTime < Now && Now < EndTime ; } Ref : http://stackoverflow.com/questions/12998739/how-to-check-if-datetime-now-is-between-two-given-datetimes-for-time-part-only

Find your Facebook ID - a 5-second easy tool for locating your Facebook numeric personal ID

Enter Facebook Page Name:    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>     <script>         $(document).ready(function ($) {             $("#btnGetPageId").click(function () {                 var companyName = $("#txtKey").val();                 //alert( companyName );                 $.ajax({                     //url: "https://graph.facebook.com/gate6agency",              ...

Kendo UI Grid Only Expand One Row at a Time

detailExpand function -------------------------------------- var grd = "#dvGrid"; $(grd).kendoGrid({                     dataSource: donorData,                     detailInit: detailInit,                     detailExpand: function (e) {                         $(grd + " tr.k-detail-row").hide();                         $(grd + " tr.k-master-row").find(".highlightrow").removeClass("activerow");              ...

Return value from function with an Ajax call [duplicate] (Jquery : call ajax and return value in function)

Jquery Code <script src="jscripts/jquery-1.7.2.min.js" type="text/javascript"></script>     <script type="text/javascript">         test();         function test() {             alert('Call Ajax Function');             myFunction(function (d) {                 //processing the data                 alert("Return Datetime from Ajax Request. The Datetime is : " + d);             });             alert('Done');         }         function myFunction(callba...

login with google in .net

public static class GoogleAuthenticationApi     {         public static string GetAuthenticationToken(string userName, string password, out bool isUserValid)         {             string response = GoogleRequestHelper.GetPostResult("https://www.google.com/accounts/clientlogin", String.Format("accountType=HOSTED_OR_GOOGLE&Email={0}&Passwd={1}&service=lh2&souce=sourceappname", userName, password), out isUserValid);             if (response.Contains("Auth="))             {                 foreach (string line in response.Split(Environment.NewLine.ToCharArray()))                 { ...

Get the number of calendar weeks between 2 dates in C#

1. const int firstDayOfWeek = 0;  // 0 = Sunday int wasteDaysStart = (7 + Convert.ToInt32(first.DayOfWeek) - firstDayOfWeek) % 7; int diff = (int)(((last - first).TotalDays + wasteDaysStart + 6) / 7); diff = diff + 1; ==================================================== 2. DateTime periodStart = first; DateTime periodEnd = last; const DayOfWeek FIRST_DAY_OF_WEEK = DayOfWeek.Monday; const DayOfWeek LAST_DAY_OF_WEEK = DayOfWeek.Sunday; const int DAYS_IN_WEEK = 7; DateTime firstDayOfWeekBeforeStartDate; int daysBetweenStartDateAndPreviousFirstDayOfWeek = (int)periodStart.DayOfWeek - (int)FIRST_DAY_OF_WEEK; if (daysBetweenStartDateAndPreviousFirstDayOfWeek >= 0) firstDayOfWeekBeforeStartDate = periodStart.AddDays(-daysBetweenStartDateAndPreviousFirstDayOfWeek); else firstDayOfWeekBeforeStartDate = periodStart.AddDays(-(daysBetweenStartDateAndPreviousFirstDayOfWeek + DAYS_IN_WEEK)); DateTime lastDayOfWeekAfterEndDate; int daysBetweenEndDateAndFollowingLast...