Wednesday, July 18, 2012

Stills from Inside the Flight

These are few of the many stills that I have captured while on board from New Delhi to Aurangabad flight .












The journey was really awesome..!!

Thanks,
Nitin Sharma

Saturday, February 18, 2012

Fetch / Get Current Date from SQL Server in a specific format

Hi All,
      Working on Saturday is really a pain...Phew...!!!!...

I came across a requirement where you have to get a Current Date from Sql Server in the following format :

DD - MM - YYYY (note the hyphen in between)


So, here is the script with the Sql Server Replace function...:



Select Replace(Convert(varchar(11),Getdate(),106),' ',' - ') as 'Today'





And the Result is :





Thanks,
Nitin Sharma

Happy Coding....

Friday, February 17, 2012

Add Twitter and Facebook like Social Sites link to ASP.NET WebSite

Hi All,
      This is my first post of the year 2012.
I came across one requirement in my recent project in which where i do have to add two share buttons for two most popular social networking sites Facebook and Twitter.

I found this HTML code to be placed in any asp.net site . Below is the code:

<a href="http://twitter.com/home?status=" target="_blank" onclick="window.open(this.href, this.target,'height=500px,width=400px'); return false">

  <img src="Images/twitter.png" alt="Share on Twitter" />

a>

<a href="http://www.facebook.com/connect/prompt_feed.php?&message=" target="_blank" onclick="window.open(this.href, this.target,'height=500px,width=400px'); return false">
  
<img src="Images/facebook.png" alt="Share on Twitter" />

a>




Thats it...and  you are ready with the share button.

Below is the snapshot of  the rendered page after click on facebook and twitter image link.

Clicking on Twitter image opens the below page as a pop up:


Clicking on Facebook image opens the below page as a pop up:





This is for sharing your own  on these two networking sites but not shareing the link or any other outside matter.


Thanks,
Nitin Sharma

Happy Coding..!!!





Tuesday, December 6, 2011

Machine Key Generator for Encrypted PasswordFormat in ASP.NET Membeship

Hello Techies,
   Here i found a MachineKey Generator ( generated in XML  tag ) , which generates your machine key that is used in applications.

Go to this URL : http://www.eggheadcafe.com/articles/GenerateMachineKey/GenerateMachineKey.aspx
Click on the button "Generate Me A Key!"

I found it when i was in need to change my PasswordFormat to "Encryted" in ASP.NET membeship.
So what you have to do is add / change the passwordFormat="Encrypted"/> and add the machine key in the tag. 

So , your web.config will have settings like this.





Asp.NET membership has "Hashed" Passwordformat by default but you have to change in web.config file for "Clear" and "Encrypted" formats. (remember both format names are case sensitive).


Thanks,
Happy coding
Nitin Sharma

Thursday, November 24, 2011

Show excel sheet data in Gridview using C#

Hi All,
   This post show how you can show data of Microsoft Excel Sheet inside a ASP.NET gridview.

The excel sheet in this example is generated by exporting the Northwind Database's Customers table . I have placed the excel sheet  in my D:\ directory and named it as "Test".

The excel sheet looks something like this :





Now on a web page take a ASP.NET GridView Control and and on the Page_load event write this code :


        string F1Name = "D:\\Test.xls";
        string CnStr = ("Provider=Microsoft.Jet.OLEDB.4.0;" + ("Data Source="
        + (F1Name + (";" + "Extended Properties=\"Excel 8.0;\""))));
        DataTable DT = new DataTable();
        OleDbDataAdapter DA = new OleDbDataAdapter("Select * from [Customers$]", CnStr);
       Response.Write("File Accessed!!!!");
        try
        {
            DA.Fill(DT);
            GridView1.DataSource = DT;
            GridView1.DataBind();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);
        }
                      

Run the WebPage and see the result as: 







Hope it will be useful.

Thanks,
Nitin Sharma