Posts

Showing posts from 2010

Required Field validation using Custom Validation for FCKEditor

//Following are the Html Part of aspx page. <FCKeditorV2:FCKeditor ID="fckeditor_test" runat="server" Height="500px" Width="520px" UseBROnCarriageReturn="true" Visible="true" > </FCKeditorV2:FCKeditor> <asp:CustomValidator ID="CustomValidator1" runat="server" ValidationGroup="validate" ClientValidationFunction="ValidateFCK" ErrorMessage="Pls Enter Some Comments"></asp:CustomValidator> <asp:Button ID="Button1" runat="server" Text="Button" CausesValidation="true" ValidationGroup="validate" /> //Following is the Javascript part   function ValidateFCK(source, args) { var FEditorID = 'ctl00_ContentPlaceHolder1_fckeditor_test'; var text = GetPlainText(FEditorID); if (text.length == 0) { args.IsValid = false; FCKeditorAPI.GetInstance(FEditorID).Focus(); return; } args.

Get Plain Text from FCKEditor in any Browser.

The Following Function will help to get plain text from the FCKEditor in almost any browser. // below is the protyping for trim string. function trimString (str) { str = this != window? this : str; return str.replace(/^\s+/g, '').replace(/\s+$/g, ''); } String.prototype.trim = trimString; //following function will return plain text function GetPlainText(FCKEditorID) { var FEditor = FCKeditorAPI.GetInstance(FCKEditorID); var Result = ""; if (FEditor.EditorDocument.body.textContent || FEditor.EditorDocument.body.textContent=="" ) { //Firefox compitable browser Result = FEditor.EditorDocument.body.textContent.trim(); } else { //IE compitable browser Result = FEditor.EditorDocument.body.innerText.trim(); } return Result; }

Ten Simple Tricks To Remembering Names

From The Following link you can find out Ten Simple Tricks To Remembering Names. Ten Simple Tricks To Remembering Names.

Nice & Cool things coming with the VS 2010 and .NET 4 release

From The Following link you can find out Nice new things coming with the VS 2010 and .NET 4 release. Scott Guthrie had explain it so nice. New Things Coming With The VS 2010 and .NET 4 release.

SFTPPro Example

first include the class in ur page using SFTPPro.SFTPServer; Example of SFTP Connection and methods Sftp sftpServer = new Sftp(strSFTPHost,strSFTPUserName,strSFTPPassword); sftpServer.Connect(); if (sftpServer.Connected) { ArrayList alFilelist=sftpServer.GetFileList(""); sftpServer.Get("strfromFilePath", "strToFilePath"); sftpServer.Put("strfromFilePath", "strToFilePath"); sftpServer.RemoveFile("<filename>"); } sftpServer.Close();

SFTPPro Example

first include the class in ur page using SFTPPro.SFTPServer; Example of FTP Connection and methods FTP FTPServer=new FTP("FtpHost", "username","password"); string []strResult=FTPServer.FileList(""); FTPServer.UploadFile("<DestinationFileName>", "<SourceFileName>"); FTPServer.DownloadFile("<SourceFileName>", "<DestinationFileName>"); FTPServer.RemoveFile("<FileName>"); FTPServer.MakeDirectory("<DirectoryName>"); FTPServer.RemoveDirectory("<DirectoryName>");

SFTPPro, FTPPro

The following url is for the dll package of SFTPPro and FTPPro http://code.google.com/p/sftppro/

Decompress .gz file in C# ASP.NET

//Following Code will help u to decompress using ICSharpCode.SharpZipLib.GZip; Stream s = new GZipInputStream(File.OpenRead(@"C:\Sample.txt.gz")); FileStream fs = File.Create(@"C:\Sample.txt"); int size = 2048; byte[] writeData = new byte[2048]; while (true) { size = s.Read(writeData, 0, size); if (size > 0) { fs.Write(writeData, 0, size); } else { break; } } s.Close(); fs.Close(); ///Following code will use to compress the file to.gz Stream s = new GZipOutputStream(File.Create(@"C:\Sample.txt.gz")); FileStream fs = File.OpenRead(@"C:\Sample.txt"); byte[] writeData = new byte[fs.Length]; fs.Read(writeData, 0, (int)fs.Length); s.Write(writeData, 0, writeData.Length); s.Close(); fs.Close(); //Download the dll from here http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx

CsharpTwitt - REST API Methods (Status Methods)

Show Statuses method support XML and JSON format. Returns a single status, specified by the id parameter below. The status's author will be returned inline. Requires Authentication : false, unless the author of the status is protected Example Twitter.PublicTwitt pubTwitt = new Twitter.PublicTwitt(); Twitter.UserTwitt userTwitt = new Twitter.UserTwitt(); string strResult = ""; XmlDocument xmlResult = null; string strUsername = "TwitterUsername"; string strPassword = "TwitterPassword"; string strStatusIDtoRetrieve = "<Numeric Status Id>"; strResult = pubTwitt.Show_Status(strStatusIDtoRetrieve, Twitter.OutputFormatType.xml); xmlResult = pubTwitt.Show_StatusAsXML(strStatusIDtoRetrieve); strResult = pubTwitt.Show_StatusAsJSON(strStatusIDtoRetrieve); //With Authentication strResult = userTwitt.Show_Status(strUsername, strPassword, strStatusIDtoRetrieve, Twitter.OutputFormatType.xml); xmlResult = userTwitt.Show_StatusAsXML(

CsharpTwitt - REST API Methods (Timeline Methods)

Public Timeline method support XML, RSS, JSON and ATOM format. Returns the 20 most recent statuses from non-protected users who have set a custom user icon. The public timeline is cached for 60 seconds so requesting it more often than that is a waste of resources. Requires Authentication : false Example Twitter.PublicTwitt pubTwitt = new Twitter.PublicTwitt(); string strResult = ""; XmlDocument xmlResult = null; strResult = pubTwitt.GetPublicTimeline(Twitter.OutputFormatType.xml); strResult = pubTwitt.GetPublicTimelineAsJSON(); xmlResult = pubTwitt.GetPublicTimelineAsXML(); xmlResult = pubTwitt.GetPublicTimelineAsAtom(); xmlResult = pubTwitt.GetPublicTimelineAsRSS(); Home Timeline method support XML, JSON and ATOM format. Returns the 20 most recent statuses, including retweets, posted by the authenticating user and that user's friends. This is the equivalent of /timeline/home on the Web. Requires Authentication : true Example Twitter.UserTwitt userTwitt = new Twitter.User

CsharpTwitt - Search API Methods

Example Search methods support only JSON and ATOM format. Requires Authentication : false Twitter.PublicTwitt pubTwitt = new Twitter.PublicTwitt(); string strResult = ""; XmlDocument xmlResult = null; strResult= pubTwitt.GetSearchResult("SearchTextAsString", true, Twitter.OutputFormatType.json); xmlResult = pubTwitt.GetSearchResultAsAtom("SearchTextAsString", true); Trends methods support only JSON format. Requires Authentication : false strResult = pubTwitt.GetTrendsResultAsJSON(Twitter.Trends.trendstype.top); strResult = pubTwitt.GetTrendsResultAsJSON(Twitter.Trends.trendstype.current); strResult = pubTwitt.GetTrendsResultAsJSON(Twitter.Trends.trendstype.weekly); strResult = pubTwitt.GetTrendsResultAsJSON(Twitter.Trends.trendstype.daily);