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)

Wednesday, 9 October 2013

404 error file not found and directory HttpError throw handle

  <httpErrors existingResponse="Replace" errorMode="Custom">

      <remove statusCode="404" subStatusCode="-1" />
      <!--<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/errorp.aspx" responseMode="Redirect" />-->
      <error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/errorpage.aspx" responseMode="ExecuteURL" />
      <error statusCode="400" path="/" responseMode="ExecuteURL" />

    </httpErrors>

  </system.webServer>