Sunday, 25 January 2015

Buttons with icon and text in Jquery




<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Button - Icons</title>

  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script> 

  <script>
      $(function () {
          $("button:first").button({
              icons: {
                  primary: "ui-icon-locked"
              },
              text: false
          }).next().button({
              icons: {
                  primary: "ui-icon-locked"
              }
          }).next().button({
              icons: {
                  primary: "ui-icon-gear",
                  secondary: "ui-icon-triangle-1-s"
              }
          }).next().button({
              icons: {
                  primary: "ui-icon-gear",
                  secondary: "ui-icon-triangle-1-s"
              },
              text: false
          });
      });
  </script>
</head>
<body>

<button>Button with icon only</button>
<button>Button with icon on the left</button>
<button>Button with two icons</button>
<button>Button with two icons and no text</button>
 
</body>
</html>





Jquery selector by patern match




1)    If you want to select elements with an id which starts with a given string (for example txtTitle):
$("[id^='txtTitle']")

2)    If you want to select elements with an id which ends with a given string:
$("[id$='txtTitle']")

3)    If you want to select elements which id contains a given string:
$("[id*='txtTitle']")

4)    If you want to select elements which id is not a given string:
$("[id!='myValue']")

5)    If you want to select elements which id contains a given word, delimited by spaces:
$("[id~='myValue']")

6)    If you want to select elements which id is equal to a given string or starting with that string followed by a hyphen:
$("[id|='myValue']")







Read URL file content and get search word count in C#



using System.Text;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Net;

protected void btnSerach_Click(object sender, EventArgs e)
{
string URIFile = string.Empty;

       URIFile = "http://ravikumargupta.com/App_Log/App_Log_20141113_03_AM.txt";

       LblCount.Text = this.URIFileWordCount("Exception", URIFile).ToString();
}

private int URIFileWordCount(string searchedWord, string url)
{
int RetVal = 0;           
string FileText;

       try
       {
              using (WebClient client = new WebClient())
              {
                    FileText = client.DownloadString(url);
              }

              Regex RExp = new Regex(searchedWord, RegexOptions.Multiline);
              MatchCollection MatchedSearch = RExp.Matches(FileText);

              RetVal = MatchedSearch.Count;
       }
       catch (Exception)
       {  
       }

       return RetVal;
}