Monday, 28 April 2014

Validation for enter key and double quot



Validation for enter key and double quot;

FilteredTextBoxExtender3.ValidChars = FilteredTextBoxExtender3.ValidChars + "\r\n";

<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server"
                                FilterType="Custom, Numbers, UppercaseLetters, LowercaseLetters" ValidChars=" !@#$%&(),./= +&quot;"  TargetControlID="txtMessage"> </cc1:FilteredTextBoxExtender>

Friday, 11 April 2014

Multiple element drag and drop

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

  <meta charset="utf-8">
  <title>jQuery UI Sortable - Connect lists</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
  <style>
  #sortable1, #sortable2 , #sortable3{ list-style-type: none; margin: 0; padding: 0 0 2.5em; float: left; margin-right: 10px; }
  #sortable1 li, #sortable2 li , #sortable3 li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 120px; }
  </style>
  <script>
      $(function () {
          $("#sortable1, #sortable2 , #sortable3").sortable({
              connectWith: ".connectedSortable"
          }).disableSelection();
      });
  </script>
</head>



<body>

<ul id="sortable1" class="connectedSortable">
  <li class="ui-state-default">Item 1</li>
  <li class="ui-state-default">Item 2</li>
  <li class="ui-state-default">Item 3</li>
  <li class="ui-state-default">Item 4</li>
  <li class="ui-state-default">Item 5</li>
</ul>

<ul id="sortable2" class="connectedSortable">
  <li class="ui-state-highlight">Item 1</li>
  <li class="ui-state-highlight">Item 2</li>
  <li class="ui-state-highlight">Item 3</li>
  <li class="ui-state-highlight">Item 4</li>
  <li class="ui-state-highlight">Item 5</li>
</ul>

 <ul id="sortable3" class="connectedSortable">
  <li class="ui-state-highlight">Item 1</li>
  <li class="ui-state-highlight">Item 2</li>
  <li class="ui-state-highlight">Item 3</li>
  <li class="ui-state-highlight">Item 4</li>
  <li class="ui-state-highlight">Item 5</li>
</ul>

</body>
</html>

Thursday, 10 April 2014

Date sorting in xsl

 <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/><br/>
    </xsl:copy>
  </xsl:template>



  <xsl:template match="INSTestElements">
    <xsl:copy>
   
      <xsl:apply-templates select="INSTestElement">
        <xsl:sort select="substring(substring-after(substring-after(Created, '/'), '/'), 1, 4)" data-type="number" order="descending"/>
        <xsl:sort select="substring(Created, 1, 2)" data-type="number" order="descending"/>
        <xsl:sort select="substring-before(substring-after(Created, '/'), '/')" data-type="number" order="descending"/>
   
      </xsl:apply-templates>
     
    </xsl:copy>
  </xsl:template>

Monday, 7 April 2014

For each for ary in xsl and xslt

 <xsl:variable name="k" select="@id" />
      <xsl:variable name="list" select="'4 5 6'" />
   
     <xsl:if test="
  contains(
    concat(' ', $list, ' '),
    concat(' ', $k, ' ')
  )
">
      hanmant <xsl:value-of select="concat('ID- ', $k, ' is in the list.')" />
      </xsl:if>

Wednesday, 26 March 2014

Excel download Number format Issue - Solution

   Response.ContentType = "application/vnd.ms-excel";
                Response.AppendHeader("content-disposition", "attachment; filename=TestFile-"+DateTime.Now.ToFileTime()+".xls");
                string style = @"<style> td { mso-number-format:""0""; } </style> ";// this is used to ensure that the big phone numbers are not converted to exponential values
                Response.Write(style);// apply style
                Response.Write(sw.ToString());
                Response.End();

Monday, 24 March 2014

Server side validation for DATE format dd/mm/yyyy

DateTime.Parse(strinput);
            string[] arr = strinput.Split('/');
            string strNewDate = arr[1] + "/" + arr[0] + "/" + arr[2];

            string strRegex = @"^(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$"; // dd/mm/yyyy
            //@"^([0]\d|[1][0-2])\/([0-2]\d|[3][0-1])\/([2][01]|[1][6-9])\d{2}(\s([0-1]\d|[2][0-3])(\:[0-5]\d){1,2})?$"; // MM/dd/yyyy

            Regex re = new Regex(strRegex);

            if (re.IsMatch(strNewDate))
                return (true);
            else
                return (false);

Thursday, 20 March 2014

Share Social Media--Hanmant

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="js/jquery-1.9.1.js"></script>

    <script language="javascript" type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
    <script language="javascript" type="text/javascript" src="https://apis.google.com/js/client:plusone.js"></script>
    <script language="javascript" type="text/javascript">

        function getplusone(url) {
            alert("googleplusones" + url);
            var plusones;
            var params = {
                nolog: true,
                id: url,
                source: "widget",
                userId: "@viewer",
                groupId: "@self"
            };

            gapi.client.setApiKey('AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ')
            gapi.client.rpcRequest('pos.plusones.get', 'v1', params).execute(function (resp) {
                //console.log('count:', resp.result.metadata.globalCounts.count)
                plusones = resp.result.metadata.globalCounts.count;
                alert("google" + plusones)
                $('#lblgoogle').append('+1 ' + plusones);
            });

        }
   
    function getfbcount(url) {
        //alert("facebook" + url);
        var fblikes;
        $.getJSON('http://graph.facebook.com/?id=' + url, function (data) {
            //fblikes = data[url].shares;
            fblikes = data.shares;
            $('#lblFB').append('fb likes ' + fblikes);
            });
    }


    function gettwcount(url) {       
        var tweets;
        $.getJSON('http://urls.api.twitter.com/1/urls/count.json?url=' + url + '&callback=?', function (data) {
            tweets = data.count;
            $('#lblTw').append('tweets ' + tweets);
        });
    }

      

    function getplusone11(url) {
        alert("googleplusones" + url);
        var plusones;
        $.getJSON('https://clients6.google.com/rpc?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ' + 'callback=?',
        {
        "method": "pos.plusones.get",
        "id": "p",
        "params": {
        "nolog": true,
        "id": url,
        "source": "widget",
        "userId": "@viewer",
        "groupId": "@self"
        },
        "jsonrpc": "2.0",
        "key": "p",
        "apiVersion": "v1"
    },
    function (data) {
        plusones = data.count;
        alert("google" + plusones)
        $('#lblgoogle').append('+1 ' + plusones);
    });
    }


$(document).ready(function () {
    $('#fbShare').attr('href', 'http://www.facebook.com/sharer.php?u=' + location.href + '&t=' + document.title);
    $('#TwitterLink').attr('href', 'http://twitter.com/share?text=' + document.title + ' ' + document.getElementById('<%=Label1.ClientID%>').innerHTML);
    $('#LinkedInLink').attr('href', 'http://www.linkedin.com/shareArticle?mini=true&url=' + location.href + '&title=' + document.title + '&summary=' + document.title + ' ' + escape(location.href));
    $('#ShareGoogle').attr('href', 'https://plusone.google.com/_/+1/confirm?hl=en&url=' + location.href);

    //var path = window.location.pathname;
    //alert("window.location.pathname : " + path);

    //var href = window.location.href;
    //alert("window.location.href : " + href);

    //var hash = window.location.hash;
    //alert("window.location.hash : " + hash);

    var url = $(location).attr('href');
    //alert("Current URL Using JQuery : " + url);

    getfbcount('http://www.yahoo.com/');
    gettwcount('http://www.yahoo.com/');
   // getplusone('http://www.yahoo.com/');
    getplusone11('http://www.yahoo.com/');

  
});
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" ForeColor="White"></asp:Label>
        <nav class="share">
            <p class="blueBgTitle">Share</p>
                <ul class="shaerMediaIcon">
                    <li class="shaerFacebook"><a id="fbShare" href="javascript:;" target="_blank"><img src="/images/facebook_32.png" alt="facebook" /></a></li>
                    <li class="shaerShapeBox"><asp:Label ID="lblFB" runat="server"></asp:Label></li>
                    <li class="gryeeVLine"></li>
                    <li class="shaerTwitter"><a id="TwitterLink" href="javascript:;"  target="_blank"><img src="/images/twitter_32.png" alt="twitter" /></a></li>
                    <li class="shaerShapeBox"><asp:Label ID="lblTw" runat="server"></asp:Label></li>
                    <li class="gryeeVLine"></li>
                    <li class="shaerIn"><a id="LinkedInLink" href="javascript:;" target="_blank"><img src="/images/linkedin_32.png" alt="linkedin" /></a></li>
                    <li class="shaerShapeBox"><asp:Label ID="lblLNK" runat="server"></asp:Label></li>

                    <li class="gryeeVLine"></li>
   
                    <li class="shaerGooglePlus"><a id="ShareGoogle" runat="server"  target="_blank"><img src="/images/google.png" alt="google" /></a></li>
                    <li class="shaerShapeBox"><asp:Label ID="lblgoogle" runat="server"></asp:Label></li>
                </ul>
                <div class="clear"></div>
                <div class="shareMore">
                        <!-- AddToAny BEGIN -->
                        <a class="a2a_dd" href="http://www.addtoany.com/share_save">More +</a>
                        <script type="text/javascript" src="http://static.addtoany.com/menu/page.js"></script>
                        <!-- AddToAny END -->
                </div>
            </nav>
    </div>
    </form>
</body>
</html>