Friday, May 27, 2011

Open a page in ModalPopUP

To Open a page in modal pop up   extender of ajax we have to use these source:

<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="lnkPopup" PopupControlID="panOpen" BackgroundCssClass="ModalBackground" CancelControlID="btnCancel" PopupDragHandleControlID="panOpen" > </ajaxToolkit:ModalPopupExtender>

<asp:Panel ID="panOpen" runat="server" Height="400px" Width="400px" CssClass="ModalWindow">

<IFRAME id="frame1" src="SourcePage.Extension / URL of the external Site" Scrolling="auto">

</IFRAME>

<asp:Button ID="btnCancel" runat="server" Text="Close" />

</asp:Panel>

<a id="lnkPopup" runat="server">Show Popup</a>

Monday, May 23, 2011

Drop all the tables by query


If you need to perform the same actions for all tables in a database, you can create cursor or you can use the sp_MSforeachtable undocumented stored procedure to accomplish the same goal with less work.

Drop all tables from database
Query is:
EXEC sp_MSforeachtable @command1 = "DROP TABLE ?"

Connection string for Excel File


For excel 2003
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Book2.xls;Extended Properties=\"Excel 8.0;HDR='YES'\"";

And For Excel 2007
 string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Book1.xlsx        Extended Properties=\"Excel 8.0;HDR=YES;\"";

Monday, May 16, 2011

Copy File From One Directory To Another

By using this code 
     string source = @"C:\Untitled-1.html";
        string dest = Server.MapPath("~/");
        string filename = "Untitled-1.html";
       File.Copy(source, dest + filename + (new FileInfo(source).Extension));