Friday, March 26, 2010

SharePoint Page Types

Do you know in SharePoint there are two types of pages?

In a SharePoint site each page you see is either a ghosted page or an unghosted page.

Ghosted (Uncustomized) Pages

These are the pages stored in the severs file system but not in the database. The other important thing is these files are common to all the site collections within the SharePoint server and are generally based on the "out of the box" site definition templates. Basically they are working as template files. Ghosted pages are faster since ASP.NET parser will be used to parse them and as you might know ASP.NET parser will compile the page into an assembly on the first time it is rendered, on subsequent executions the compilation is skipped since the assembly is already there.

When ghosted pages are modified by SharePoint designer then they will become unghosted pages, and then SharePoint will start using that file in the future not the file stored in the file system. A common example for this would be the “default.master” file on the “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\Global“.

Unghosted (Customized) Pages

These are the pages which are stored on the database. Unghosted pages are specific to the SharePoint web site the page is in. If you change these files it will not affect any other site in the same SharePoint server. Unghosted pages will be parsed by the safemode parser which will not compile the pages. The only dynamic code allowed is server-side controls that are marked safe (Safe Controls, Trusted Controls).

Why Ghosting?

This allows SharePoint to,

  • Increase it’s performance by enabling caching the main site template into memory and then apply the changes that are stored in the database for the specific file.
  • Increases security by not allowing unghosted pages to run code so an attacker who injects code will not be able to crash your server.

Tuesday, March 23, 2010

Finding the IP Address of the Email Sender

Recently I was bit curios to find out whether we can find the IP address of the sender in an email. After doing some web searching I found interesting sites which describes what needs to be done.

If you like to find out the way to do this please visit and see.

http://www.johnru.com/active-whois/trace-email.html

http://aruljohn.com/info/howtofindipaddress/

Saturday, March 13, 2010

Protect HTML Files

Recently I came up with a requirement to protect a website which was created using HTML.

When searching over the internet a team member of mine found a nice software called HTML Guard.

This software is encoding the source of the site so the users will not be able to see the code behind the site. Using this tool you can even block a site to a particular domain. Even the site is downloaded it will not properly run.

The best thing is this has a free version so we can use the full set of features without paying (A small message will come on the top right corner saying the site is encoded by using the tool).

This software is by WulfSoft, thanks guys you have done a good job.

Try out yourself and see.

http://www.htmlguard.com/

Reading and Writing to Excel Files

Even though I posted similar 2 articles in 2008, the code of that article was having few errors. So thought to put more complete post on this.

The code will read an Excel file using an OleDbConnection and will write the same data back to another Excel file. This will explain how to read and write to Excel files. One thing to remember when running this code is to make sure the source Excel file is open. Otherwise you will get an error similar to “External table is not in the expected format.”

Also note that there are few connection string parameters you can use while opening Excel files.

HDR = Yes – Use when first row contains column headers.

HDR = No  - Use when first row contains data.

Excel xx.x – Use the following Table as a guide.

Parameter Value

Excel Version

Excel 12.0 Excel 2007 (Released in 2007)
Excel 11.0 Excel 2003 (Released in 2003)
Excel 10.0 Excel XP (Released in 2001)
Excel 9.0 Excel 2000 (Released in 1999)
Excel 8.0 Excel 97 (Released in 1997)

 

IMEX=1 – Use this when you want to treat all your data in the file as text.

For example - >

Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1";

To make the code to work properly you need to refer the Microsoft.Office.Interop.Excel assembly by adding a reference to your project.





  1. using System;
  2. using System.Data;
  3. using System.Windows.Forms;
  4. using System.Data.OleDb;
  5. using Microsoft.Office.Interop.Excel;
  6. namespace TestApp
  7. {
  8.     public partial class Form1 : Form
  9.     {
  10.         public Form1()
  11.         {
  12.             InitializeComponent();
  13.         }
  14.         private void button1_Click(object sender, EventArgs e)
  15.         {
  16.             openFileDialog1.ShowDialog();
  17.             // Create an OLEDBConnection to connect to the Excel file.
  18.             // I'm getting the required file by using a file dialog.
  19.             // The @ symbol makes the string to contain any special characters inside the string without breaking the string.
  20.             OleDbConnection dbConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + openFileDialog1.FileName.ToString() + @";Extended Properties=""Excel 8.0;HDR=Yes;""");
  21.             // Open the connection.
  22.             dbConnection.Open();
  23.             // Create a command object to work on the data.
  24.             // Note that I have given the sheet name as [Sheet1$] to retrieve data from that named sheet in the particular Excel file.
  25.             OleDbCommand dbCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", dbConnection);
  26.             // Creating a data reader to read data.
  27.             OleDbDataReader dbReader = dbCommand.ExecuteReader();
  28.             // If needed you can get the position of any column (e.g. Age), this will only work if you use HDR=Yes.
  29.             int SearchingItem = dbReader.GetOrdinal("Age");
  30.             // Create the Excel Application object.
  31.             ApplicationClass ExcelApp = new ApplicationClass();
  32.             // Set the visibility of the application.
  33.             ExcelApp.Visible = true;
  34.             // Create a new Excel Workbook.
  35.             Workbook ExcelWorkbook = ExcelApp.Workbooks.Add(Type.Missing);
  36.             // Create a new Excel Sheet.
  37.             Worksheet ExcelSheet = (Worksheet)ExcelWorkbook.Sheets.Add(ExcelWorkbook.Sheets.get_Item(1), Type.Missing, 1, XlSheetType.xlWorksheet);
  38.             // Will keep the current row index. This should start from 1 since the first row is 1.
  39.             int CurrentRowIndex = 1;
  40.             try
  41.             {
  42.                 // Read through the data.
  43.                 while (dbReader.Read())
  44.                 {
  45.                     // Traverse through all the data columns.
  46.                     for (int i = 0; i < dbReader.VisibleFieldCount; i++)
  47.                     {
  48.                         ExcelSheet.Cells[CurrentRowIndex, i + 1] = dbReader.GetValue(i);
  49.                     }
  50.                     CurrentRowIndex++;
  51.                 }
  52.                 // Save the Excel sheet.
  53.                 // The @ symbol makes the string to contain any special characters inside the string without breaking the string.
  54.                 ExcelApp.Save(@"C:\Projects\Ex.xls");
  55.             }
  56.             catch (Exception ex)
  57.             {
  58.                 MessageBox.Show(ex.ToString());
  59.             }
  60.         }
  61.     }
  62. }




Friday, March 05, 2010

Project has Stopped Working

If you create a .NET application to use SQL CE database when you try to run your application on a Windows Vista or Windows 7 machine you might get an error saying your application did stop working, and the error details might show that your are having a problem with System.Data.SQLServerCE.

The reason for this is that your system is not having the SQL Server CE runtime in your machine. To fix it what you need to do is to install the Microsoft SQL Server Compact 3.5 Service Pack 1 on your system. You can download it from the following Microsoft link.

http://www.microsoft.com/downloads/details.aspx?FamilyId=DC614AEE-7E1C-4881-9C32-3A6CE53384D9&displaylang=en

Wednesday, February 17, 2010

An error shown when you try to start the SharePoint Search service

After installing the SharePoint Server when you try to start the search service you might end up with the following error.

An unhandled exception occurred in the user interface.Exception Information: OSearch (Administrator)

or

An unhandled exception occurred in the user interface.Exception Information: OSearch (UserName)

If this comes don’t panic, what you need to do is when providing the username provide it with the full domain name. For example Domain.Local\Administrator.

image

You can find the Microsoft knowledge base article here.

Windows Mobile 7

Highly awaited Windows Mobile 7 is at last showing in horizon.

Have a glance at it by visiting the following URL.

http://www.microsoft.com/presspass/presskits/windowsphone/videoGallery.aspx?contentID=mobileworldcongress2010

http://www.microsoft.com/windowsmobile/en-us/cmpn/windowsphone7series/default.mspx

http://www.windowsphone7series.com/

Microsoft is planning to release phones with Windows Mobile 7 at the end of 2010.

Sunday, February 14, 2010

How Networks Work

I found a really good video which explains how data is travelled in the network. This explains in simple words with animation about the tasks done by the following main components and more.

  • Packet
  • Router
  • Switch
  • Firewall

If anyone is interested in networking I highly recommend you to watch this.

Thursday, February 04, 2010

Making Reliable Connections in BlackBerry Applications

Recently I came up across a blog which provides valuable information on the connections we can make in a BlackBerry application.

If you are interested read more at the following URL.

http://www.localytics.com/blog/post/how-to-reliably-establish-a-network-connection-on-any-blackberry-device/

Tuesday, December 29, 2009

BlackBerry Security Permissions

If you are eager to find out about BlackBerry security permissions and ways to handle prompts following video from BlackBerry will help you in understanding the basics of it.

http://www.blackberry.com/DevMediaLibrary/view.do?name=SecurityPrompts

Further more if you are seeking ways to change application permissions using code, following link will help you to get more details of the Application Permissions class from RIM device API.

http://docs.blackberry.com/en/developers/deliverables/6022/net/rim/device/api/applicationcontrol/ApplicationPermissions.html#PERMISSION_INPUT_SIMULATION

Monday, December 28, 2009

Disabling Date-Time Changes

Do you know that you can programmatically stop the user changing the date and time of a Pocket PC device?

This is useful if your applications need to take time accurately for some reason from the device.

The following code will disable the user from accessing the date time changing settings using his Windows Mobile powered device.





  1. private void btnDisableClock_Click(object sender, EventArgs e)
  2. {
  3.     RegistryKey hklm = Registry.LocalMachine;
  4.     hklm = hklm.OpenSubKey(@"\Software\Microsoft\Clock\", true);
  5.     System.Byte[] offValue = new byte[1];
  6.     offValue[0] = 0x30;
  7.     hklm.SetValue("AppState", offValue);
  8.     lblTitle.Text = "Change Clock Status - Disabled";
  9. }




 

If you want to re-enable the setting, to make the user able to change the data and time use the below code.





  1. private void btnEnableClock_Click(object sender, EventArgs e)
  2. {
  3.     RegistryKey hklm = Registry.LocalMachine;
  4.     hklm = hklm.OpenSubKey(@"\Software\Microsoft\Clock\", true);
  5.     System.Byte[] offValue = new byte[1];
  6.     offValue[0] = 0x11;
  7.     hklm.SetValue("AppState", offValue);
  8.     lblTitle.Text = "Change Clock Status - Enabled";
  9. }




Saturday, December 19, 2009

Boeing 787 - DreamLiner

Boeing's newest plane 787 DreamLiner had made its first flight. As of Boeing this is a great achievement and a history changer.
View the video and lots of other details at New Air Plane and Boeing.