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>

Tuesday, 29 October 2013

Jquery bind server side in cs pages

 System.Text.StringBuilder strScriptFB = new System.Text.StringBuilder();
        strScriptFB.Append("<script type=\"text/javascript\">");
        strScriptFB.Append("$(document).ready(function () {");
        strScriptFB.Append("jQuery.getScript('http://connect.facebook.net/en_US/all.js', function () { });");

        strScriptFB.Append("$('#divFBLike').append('<div id=\"fb-root\"></div>');");
        strScriptFB.Append("$('#divFBLike').append('<div class=\"fb-like\" data-href=\"" + strFacebookHTTP + "/idfc-tv-playing.aspx?Vid=" + SessionManager.intVideosID.ToString() + "&fbvidID1234=" + SessionManager.intVideosID.ToString() + "&isValid=1\"data-send=\"false\" data-width=\"210\" height=\"300\" data-show-faces=\"false\"></div><p>&nbsp;</p>');");
        strScriptFB.Append("$('#facebookHolder').append('<fb:comments href=\"" + strFacebookHTTP + "/idfc-tv-playing.aspx?Vid=" + SessionManager.intVideosID + "&fbvID23=" + SessionManager.intVideosID.ToString() + "&isValid=1\" num_posts=\"2\" width=\"213\"></fb:comments>'); ");
        strScriptFB.Append("}); </script>");

        ScriptManager.RegisterClientScriptBlock(this.Page, GetType(), "alert1", strScriptFB.ToString(), false);

Wednesday, 16 October 2013

Bind Dropdown use xml, Dropdown fill by xml

  DataSet  ds= new DataSet();
        ds.ReadXml(Server.MapPath("BindXMLToDropDown.xml"));

        DropDownList1.DataSource = ds;
        DropDownList1.DataTextField = "category";
        DropDownList1.DataValueField = "lastUpdated";
        DropDownList1.DataBind();

Friday, 11 October 2013

Save live image in c sharp

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
 -----------------------------------------
 protected void Button1_Click(object sender, EventArgs e)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(TextBox1.Text.Trim());
        string filname = TextBox1.Text.Trim();
        filname = string.Format("{0:MMMMyyyyHHmmssFFFF}", DateTime.Now) + filname.Substring(filname.LastIndexOf("/") + 1);

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        if ((response.StatusCode == HttpStatusCode.OK ||
                   response.StatusCode == HttpStatusCode.Moved ||
                   response.StatusCode == HttpStatusCode.Redirect) &&
                   response.ContentType.StartsWith("image", StringComparison.OrdinalIgnoreCase))
        {
            using (Stream inputStream = response.GetResponseStream())
            using (Stream outputStream = File.Create(Server.MapPath("images") + "\\" + filname + ""))
            {
                byte[] buffer = new byte[4096];
                int bytesRead;
                do
                {
                    bytesRead = inputStream.Read(buffer, 0, buffer.Length);
                    outputStream.Write(buffer, 0, bytesRead);
                } while (bytesRead != 0);
            }
        }
    }

Sum one by one ,Second highest salary

select a.Id, a.Name, sum(b.Name) as sum from Table_5 a cross join Table_5 b where b.Id <= a.Id group by a.Id, a.Name



Select * From Table_5 T1 Where 3=(Select Count(Distinct(t2.salary)) From Table_5 T2 Where T2.salary > T1.salary)



select min(name) from Table_5 where name in (select   distinct top 5 name  from Table_5 order by name desc)