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>

Tuesday, 11 March 2014

One xsl and multipale xml read , direct xml read in xsl

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.Net;
using System.IO;
using System.Xml;
using System.Xml.Linq;

public partial class xmlxsl : System.Web.UI.UserControl
{
    public string xmlfile = "";
    public string xslfile = "";
    public string xslxmlfile = "";
    public string xslxmltxt = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        string myXmlFile = Server.MapPath(xmlfile);
        XPathDocument myXPathDoc = new XPathDocument(myXmlFile);
        XslCompiledTransform myXslTrans = new XslCompiledTransform();
        string myStyleSheet = Server.MapPath(xslfile);
        XsltSettings xs = new XsltSettings(true, true);
        XmlUrlResolver xur = new XmlUrlResolver();
        myXslTrans.Load(myStyleSheet, xs, xur);

        myXslTrans.Transform(myXmlFile, Server.MapPath(xslxmlfile));
        string strHTML = GetHTML(Server.MapPath(xslxmlfile)); ;
        strHTML = strHTML.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
        divHTML.InnerHtml = strHTML;


    }
    public string GetHTML(string strURL)
    {
        string strResult = string.Empty;
        try
        {
            WebResponse objResponse;
            WebRequest objRequest = HttpWebRequest.Create(strURL);
            objResponse = objRequest.GetResponse();
            using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
            {
                strResult = sr.ReadToEnd();
                sr.Close();
            }
        }
        catch (Exception ex)
        {
            // Response.Write(ex.ToString());
        }
        return strResult;
    }
}

-----------------------------------xsl--------------------------------
<?xml version="1.0" encoding='utf-8'?>
<xsl:stylesheet xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>
  <xsl:template match="/">
    <html>
      <head>
        <title> XSLT with XML included </title>
      </head>
      <body style="background-color:lightblue;color:green">
        <table cellSpacing="0" border="1" cellPadding="2">
          <!-- Set Variables -->
          <xsl:variable name="external">
            <xsl:copy-of select="/test/child2.xml"/>
          </xsl:variable>
          <!-- Process Data Start -->
          <xsl:for-each select="//UK_Products_Pipeline/LastFinishCode">
            <tr>
              <xsl:if test="SiteName ='MWB'">
                <td>
                  <xsl:value-of select="SiteName"/>
                </td>
                <td>
                  <xsl:value-of select="LastFinishCode"/>
                </td>
                <td>
                  <xsl:value-of select="Numbers"/>
                </td>
              </xsl:if>
            </tr>
          </xsl:for-each>
          <!-- Process File Data Start -->
          <xsl:call-template name="ExternalData">
         
            <xsl:with-param name="data" select="$external"/>
          </xsl:call-template>
        </table>
      </body>
    </html>
  </xsl:template>
  <xsl:template name="ExternalData">
 
    <xsl:param name="data"/>
   
    <xsl:variable name="external">
      <xsl:copy-of select="/test/child1.xml"/>
    </xsl:variable>
    <table cellSpacing="0" border="1" cellPadding="2" style="background-color:white;color:black">
      <tr>
        <td colspan="3" align="center">
          I do see this.
        </td>
      </tr>
      <!-- Process External Data -->
     
      <xsl:for-each select="document('http://localhost:2115/Xml_transform_xslt/test/child2.xml')//UK_Products_Pipeline/LastFinishCode">
        <tr>
          <td colspan="3" align="center">
            <xsl:value-of select="SiteName"/>
          </td>
        </tr>
        <tr>
          <xsl:if test="SiteName ='UK'">
            <td>
              <xsl:value-of select="SiteName"/>
            </td>
            <td>
              <xsl:value-of select="LastFinishCode"/>
            </td>
            <td>
              <xsl:value-of select="Numbers"/>
            </td>
          </xsl:if>
        </tr>
      </xsl:for-each>
    
    </table>
  </xsl:template>
</xsl:stylesheet>
-------------------xml 1----------
<?xml version="1.0" encoding="utf-8"?>
<UK_Products_Pipeline>
  <LastFinishCode>
    <SiteName>UK</SiteName>
    <LastFinishCode>Agent Logout</LastFinishCode>
    <Numbers>1</Numbers>
  </LastFinishCode>
  <LastFinishCode>
    <SiteName>UK</SiteName>
    <LastFinishCode>Busy</LastFinishCode>
    <Numbers>1</Numbers>
  </LastFinishCode>
  <LastFinishCode>
    <SiteName>UK</SiteName>
    <LastFinishCode>BW Sale</LastFinishCode>
    <Numbers>1 koli</Numbers>
  </LastFinishCode>
</UK_Products_Pipeline>
------------------xml 2-----------------
<?xml version="1.0" encoding="utf-8"?>

<UK_Products_Pipeline>
  <LastFinishCode>
    <SiteName>MWB pramodhanmant</SiteName>
    <LastFinishCode>Bearer Capability Not Presently Authorized (ISDN Cause Code 57)</LastFinishCode>
    <Numbers>1 hanmant</Numbers>
  </LastFinishCode>
  <LastFinishCode>
    <SiteName>MWB</SiteName>
    <LastFinishCode>Confirmed Booking</LastFinishCode>
    <Numbers>1 hanmant</Numbers>
  </LastFinishCode>
  <LastFinishCode>
    <SiteName>MWB</SiteName>
    <LastFinishCode>Lost</LastFinishCode>
    <Numbers>1 hanmant</Numbers>
  </LastFinishCode>
</UK_Products_Pipeline>

Sunday, 19 January 2014

IsCrossPagePostBack and find previous pages usercontrol value to another page

 if (Page.PreviousPage != null && Page.PreviousPage.IsCrossPagePostBack)
            {
                ContentPlaceHolder cph = (ContentPlaceHolder)Page.PreviousPage.Master.FindControl("MainContent");
                if (cph != null)
                {
                    UserControl ucViewLocateUs = (UserControl)cph.FindControl("ViewLocateUs1");
                    if (ucViewLocateUs != null)
                    {
                        DropDownList dpdListCity = ucViewLocateUs.FindControl("dpdListCity") as DropDownList;
                        FillAllLocateUsDetails(dpdListCity);
                    }
                }
            } 

Wednesday, 15 January 2014

Default button click on enter use javascript

<script type="text/javascript">
    if (document.addEventListener) {//if Firefox
        document.addEventListener("keypress", fireFoxHandler, true);
       
    } else {
       
        document.attachEvent("onkeyup", ieHandler);
    }
   
    function fireFoxHandler(evt) {
        if (evt.keyCode == 13) {
            document.getElementById("btnSave").click();
           
        }
    }

    function ieHandler(evt) {
        if (evt.keyCode == 13) {
            document.getElementById("btnSave").click();
        }
    }

</script>

<asp:Button ID="btnSave" ValidationGroup="Submit" runat="server" Text="Save" OnClick="btnSave_Click"
                    CssClass="save_btn" ClientIDMode="Static" />

Monday, 23 December 2013

Add Remove Header Tag inside Tag Meta,Title,Canonical,link etc

 this.Page.Header.Title = "page title";
               
                    HtmlLink link = (HtmlLink)Page.Header.FindControl("idcanonical");
                    Page.Header.Controls.Remove(link);
                
                   HtmlLink link1 = new HtmlLink();
                    link1.Href = "http://www.test.com/equity-funds";
                    link1.Attributes["rel"] = "canonical";
                    this.Page.Header.Controls.Add(link1);

                    HtmlMeta metadesc = (HtmlMeta)Page.Header.FindControl("meta_funds");
                    Page.Header.Controls.Remove(metadesc);

                    HtmlMeta metakey = (HtmlMeta)Page.Header.FindControl("keywords_funds");
                    Page.Header.Controls.Remove(metakey);

                    HtmlMeta metadesc1 = new HtmlMeta();
                    metadesc1.Name = "Description";
                    metadesc1.Content = "test.";
                    this.Page.Header.Controls.Add(metadesc1);

Thursday, 12 December 2013

MVC paging

http://www.codeproject.com/Articles/28605/Pagination-Class-for-ASP-NET-MVC

Wednesday, 4 December 2013

Google plus api intigration

 https://developers.google.com/+/web/+1button/
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
      <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
 <a href='javascript:;' title="Google+" target="_blank" class="g-plusone" data-size="small" data-href="http://www.pramod.com">
                      
                        </a>
    </div>
    </form>
</body>
</html>