Wednesday, June 29, 2011

HTML5

Hi friends
i am back with a new thing:) might be the old one for code guru. Today i was looking into the new HTML version HTML5.

This is the latest version on HTML which is launched to make sure that HTML is not legging behind with the world. In today's net savvy world we have different type of videoes, audioes,pictures showing on the websites. These all items need different plug in to run with like flash player, but now no plugin is required:)

below are some of the tags which make your life so much easy in the world of html.
1) audio- For playing sounds, music or other audio streams
2) video- For showing video content, such as a movie clip or other video streams
3) source- For media resources for media elements, defined inside video or audio elements
4) embed- For embedded content, such as a plug-in
5) Canvas - The HTML5 canvas element uses JavaScript to draw graphics on a web page. using this you can create images on the webpage itself file filled rectangle
6) localStorage - stores data with no time limit, this will be the replacement for cookies so that you can keep the big data on client side also without hammpering the performance of the application
7)SessionStorage - stores data for one session and when you close the browser all the data will be lost.

Here are some of the new input types which is supported in HTML5. These type will life of developer much simpler as developer don't have to write javascript for validation of these types.

1) email= if you put the input type as email then this type will make sure that user enter the email address only. another words it will do validation for email address format and if your browser don't support it it will show as simple input type.
2) url= It will validate the text box for URL format
3) number= It will validate the number format. it also support the max and min number user can enter in input box. there is one more feature call step so it will show the number as the step value you have defined.
4) range= this will make the range for the number like min to max value.
5) Date pickers (date, month, week, time, datetime, datetime-local)- it will set date time value in text box and user can select the appropriate date time values
6)search-The search type is used for search fields, like a site search, or Google search.
7) color- validation for color number values (Chrome support hexadecimal values and safari will show the color picker it self for user to select any of the colors)
8) placeholder- this will show the message in text box and when user click on the text box the value goes off. this will be like information for the content of the input text box.

check the below site for more and better understanding.

Monday, July 26, 2010

Warning 1 Use command line option '/keyfile'

This is the common Warning message we usuall get when we build a 1.1 framework project in newer version like 2.0 or 3.5. I got the warning as below.
Warning 1 Use command line option '/keyfile' or appropriate project settings instead of 'AssemblyKeyFile'

I had never noticed the warning before, but looked into some of the past builds and noticed that it had always been there. After doing some research, I found out that Visual Studio 2005 now considers the use of setting the AssemblyKeyFile in the AssemblyInfo.cs file a security issue. This is due to the AssemblyKeyFile attribute being embedded within your assembly and possibly containing sensitive path information. The warning also recommended setting this information via the project settings. I use an external strong name key file for all of my assemblies. It resides outside all of my projects/solutions. When I referenced this strong name key file, VS2005 copied it into the project. This wasn't a good thing at all.


If you are using Visual Studio 2005, you can use Project Settings (right click project name in solution explorer) to sign the assembly.

Sunday, April 26, 2009

Upload files on Secure FTP

hi friends
i am having trouble with the Secure ftp site. i was not able to upload the files on the secure ftp site using my code. the code works good if the ftp site don't have the Secure SSI connection. then i have written a code which uses FtpWebRequest for uploading the data on secure ftp site. In this code i have one problem about the Certificates which should be issued in order to make it secure sit. i don't have that certificates so i have written a static method which will make the certification value as valid in any case. here is the code. hope it will help you guys
public bool SecureConnection(string UrlPath, string UserName, string Password,string command,string filePath,string fileName) { try { //String serverUri = "ftp://ftpsite.com/folder1/Test"; if (command.Equals("UF")) UrlPath = UrlPath + "//" + fileName; //String serverUri =UrlPath; FtpWebRequest request = (FtpWebRequest)WebRequest.Create(UrlPath); request.Credentials = new NetworkCredential(UserName, Password); request.UsePassive = true; request.EnableSsl = true; switch (command) { case "MD": if(SecureConnectionRemoveDirectory(UrlPath,UserName,Password)) request.Method = WebRequestMethods.Ftp.MakeDirectory; break; case "UF": request.Method = WebRequestMethods.Ftp.UploadFile; StreamReader sourceStream = new StreamReader(filePath); byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd()); sourceStream.Close(); request.ContentLength = fileContents.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(fileContents, 0, fileContents.Length); requestStream.Close(); break; } ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateServerCertificate); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); } catch (Exception _exp) { return false; } return true; } public static bool ValidateServerCertificate(object sender,X509Certificate certificate, X509Chain chain,SslPolicyErrors sslPolicyErrors) { return true; }

Tuesday, April 21, 2009

Finding Number of Rows in UltraGrid

Hi friends
Today i was working on Ultra Grid provided by
Infragistics. I found out a typical problem. There is a scenario where i have to find the number of rows selected in the grid. These number of rows are not by selecting the check boxes in the grid cell but by CTR-Click combination. i can check the activated row by the active index properties but now i have to select all the rows which i have previously selected with the holding the control button. Below is the code which might be helpful for you.


public ArrayList GetSelectedAccount(Infragistics.Win.UltraWinGrid.UltraGrid dgAccount)
{
ArrayList AccountArray = new ArrayList();
CurrencyManager cmAccount = (CurrencyManager)this.BindingContext [dgAccount.DataSource, dgAccount.DataMember];
DataView dvAccount = (DataView)cmAccount .List;
for (int i = 0; i < dvAccount .Count; ++i)
{
if (dgAccount.Rows[i].Selected)
{
AccountArray.Add(dgAccount.Rows[i].Cells["AccountID"]);
}
}
messagebox.show(AccountArray.length.tostring());
}
[/CODE]

Wednesday, February 11, 2009

Find Birthday in SQL query

I was having trouble with this particular query from quite some time. I have fixed this problem with some patch up. But the solution was not permanent. The problem is keep coming in the one or the other form. Then one of my colleagues suggested a solution for the problem. I was really happy to get that solution. It was a small change in the way i was putting the logic. I was using date part function of and then find the day and then month and then compare both values (day & month) of start and end date with DOB of the employee. That logic was getting complex and confusing too. My colleague suggested me to make use of the dayofyear option in the date part. dayofyear will get us the unique number for the day in whole year. Just like 1st Jan 2008 or 1 Jan 2009 it will be return us as 1 it doesn't depend on which year it's falling.

Here is the SQL query to find birthday of all the contacts between two date

SELECT COALESCE(C.FirstName,'')
FROM Tb_Customer C WITH (NOLOCK)
WHERE dob IS NOT NULL AND datepart(dayofyear,dob) BETWEEN datepart(dayofyear,getdate()) AND datepart(dayofyear,dateadd(m,3,getdate()))

Tuesday, January 6, 2009

SQL Server 2008: "Saving changes is not permitted"

When trying to save a table in SQL Server 2008 error comes up "Saving changes is not permitted" The statement is like this
Saving changes is not permitted. The changes that you have made require the following tables to be dropped and re-created. You have either made changes to a table that can't be re-created or enabled the option Prevent saving changes that require the table to be re-created.
While searching on the net i found out that there are some more chnages which we do on the table in SQL server 2008 and that will cause same error above.

Below are some of the
  1. change the Allow Nulls
  2. setting for a column.
  3. reorder columns in the table.
  4. change the column data type.
  5. add a new column.

This Warning message pops up because we create a New schema for the Table. This schema change might loose already existing data in the table it will also change the meta data of the table.
To get rid of this waring message

  1. Open SQL Server Management Studio (SSMS).
  2. On the Tools menu, click Options. In the navigation pane of the Options window,
  3. click Designers. Select or clear the Prevent saving changes that require the table re-creation check box, and then click OK.

If you disable this option, you are not warned when you save the table that the changes that you made have changed the metadata structure of the table. In this case, data loss may occur when you save the table.

Monday, January 5, 2009

Create a text file using Dataset or Datatable in C#

I am currently working with the Dataset. I had a requirement in which i have to write a functionality in which all the data is written to the text file. The requirement is like create a text file and all the columns will be separated by tilde symbol. Below is the sample code which will solve the problem.
void CreateTextfile(string FilePath,Datatable dt)
{
int i = 0;
StreamWriter swTextFile= null;
try
{
swTextFile= new StreamWriter(filePath, false);
for (i = 0; i < dt.Columns.Count - 1; i++)
{
swTextFile.Write(dt.Columns[i].ColumnName + " ");
}
swTextFile.Write(dt.Columns[i].ColumnName);
swTextFile.WriteLine();
foreach (DataRow row in dt.Rows)
{
object[] array = row.ItemArray;
for (i = 0; i < array.Length - 1; i++)
{
swTextFile.Write(array[i].ToString() + "~");
}
swTextFile.Write(array[i].ToString());
swTextFile.WriteLine();
}
swTextFile.Close();
}
catch (Exception ex)
{
throw ex;
}
}