Sunday, August 30, 2009

Another CMS For ASP.Net

This article is a followup on my last article about CMS for ASP.Net.

These two are of the many promising CMS for the Microsoft ASP.Net platform today. One is a CMS for enterprise and the other one is using Microsoft's latest technology called Silverlight. Check the following below:

1. AxCMS (Enterprise Content Management)

The AxCMS.net is a cost free Enterprise Content Management System. By integrating numerous modules the system offers a comprehensive list of features for creating and managing Inter-, Extra- and Intranet-presentations.

2. Media Courtyard (ASP.Net CMS)

The CMS package offered by Media Courtyard is one of the most advanced solutions available. Utilizing the latest Silverlight technology to provide a simple but powerful and easy to use interface that makes everyday web content creation/management an easy and enjoyable task.

Our CMS is based on .NET 3.5 and SQL Server database technology ensuring web pages are delivered to your visitors quickly and reliably. The built-in membership system allows users to register to your website and contribute using the built-in commenting module.

Microsoft's Ad Agency has been sued...

Microsoft's Ad agency JWT and its parent WPP has been sued by a Delaware firm called Denizen which claims to have patented a particular program "The Philantropist" which Microsoft incorporated its Bing (their new search engine) Ad.

Watch the video here.

Read the whole news article by Chris Crum here.

Tuesday, August 25, 2009

Opensource And Commercial ASP.Net CMS

I've been googling around lately where to find an opensource CMS (Content Management System)on ASP.Net platform. There are a number of very mature and stable CMS for .Net that I've found. Below are the links and description.

Opensource ASP.Net CMS

1. Umbraco CMS (http://umbraco.org)

Umbraco CMS has been around lately and it is a CMS that can support any browser and that even allows editing by using Microsoft Word.

2. Dave's ASP.Net CMS (http://www.davidpirek.com/cms/)

Dave's ASP.NET SEO Friendly CMS was created as a response to identifying need of many small business owners for a compact easy to use content management system. This CMS was inspired by Wordpress as a simple ASP.NET alternative for those who do not have option of Linux hosting. Currently Dave’s ASP.NET CMS includes a simple blogging functionality and a zone based editing as well as a simple lead form.

3. DotNetNuke CMS (http://www.dotnetnuke.com/)

DotNetNuke CMS comes in two versions namely the free Community Edition that runs hundreds of thousands of production websites and the new Professional Edition 5.1 that includes unique features designed for business critical websites.

The DotNetNuke web content management system (CMS) and application development framework was developed as an open source, community-driven project. It continues to thrive and benefit from an established and active group of users, developers, system integrators, module vendors, skin vendors, and hosting providers.

In addition to creating and maintaining the DotNetNuke framework, DotNetNuke Corp. also leads the DotNetNuke ecosystem through which DotNetNuke users and customers gain access to a wide variety of complementary technologies, services, and hosting alternatives.

Commercial ASP.Net CMS

1. Graffiti CMS (http://graffiticms.com/)

Graffiti is built for everyday people. You don't even have to know how to program your DVR to use it!

Now we did realize that designers would want to customize how Graffiti looks. So we decided to introduce a neutral programming concept we call Chalk. Chalk is a simple templating language that gives both designers and developers the ability to customize how content is shown without requiring them to read a 500 lb. book on programming.

Yes, Graffiti is built on .NET. And truth be told, any good developer can make either PHP or ASP.NET code perform. However, we think there are better tools and more long-term advantages in Microsoft's platform. So for developers familiar with ASP.NET, Graffiti's full power and capability are readily available to you.

Graffiti CMS comes with a free edition.

2. Kentico CMS (http://www.kentico.com/)

Why should I develop web sites with Kentico CMS?

With Kentico CMS, you can achieve better results with less effort and in shorter time than with traditional development by leveraging:

fast, browser-based development with minimum coding
tons of ready-to-use web parts and modules
high flexibility and full control over rendered HTML code
open and extensible architecture
Rapid web site development

Let's face it: traditional web site development with tedious coding using basic ASP.NET infrastructure is too complex, repetitive and expensive. You can hardly justify the costs of such development in the era of content management systems that provide ready-to-use frameworks oriented on storing, updating and publishing content.

Kentico CMS provides a flexible, content-oriented framework based on ASP.NET platform that allows you to cut the development time from hours to minutes. What used to require writing ADO.NET code, SQL queries and using databound controls, can be done with a few mouse-clicks in Kentico CMS.

Kentico CMS comes with a free edition.

3. Sitefinity CMS (http://www.sitefinity.com/)

Meet the web content management system that requires no additional learning. Engineered for extensibility and customization, Sitefinity can help you deliver compelling web applications in a much shorter time than you would ever expect.

Sitefinity CMS is brought to you by Telerik, the company who designed nice 3rd party controls for .Net.

So far ASP.Net has been competing with PHP in terms of CMS tools. And now, there are a lot of CMS tools for us to choose from. I hope you guys found your ideal CMS tool to build your next project.

Goodluck!!

Friday, August 21, 2009

Utility for Microsoft.Net Developers

Developing DAL (Data Access Layer) like LINQToSQL, Entity Framework, etc. would be time consuming for someone especially if you want to concentrate more on the other stuff of your project. Now here comes a utility called Subsonic - is A Super High-fidelity Batman Utility Belt that works up your Data Access (using Linq in 3.0), throws in some much-needed utility functions, and generally speeds along your development cycle.

It is an opensource project developed by Rob Connery and other .Net Developers. It simplifies the development of your .Net projects in areas of Data Access, etc.

Give it a shot. Here's the link - http://subsonicproject.com/

Wednesday, August 19, 2009

Future cloud apps won't need humans (From ZDNet Australia)

Lew Tucker, vice president and chief technology officer of cloud computing at Sun Microsystems, foresees applications that are entirely self-sufficient.

How to Use FileUpload Control in ASP.Net 3.5

The File Upload Control is designed for applications that let you upload files to the website. This might be photos, documents and other files. This control displays a text box that lets the user enter the path for the file to be uploaded, plus a Browse button that displays a dialog box that lets the user locate and select the file.

To upload a selected file, you must also provide a separate control that results in a postback, like the Upload Button in the figure below. When the user clicks this button, the page is posted and the file selected by the user is sent to the server along with the HTTP request.



The ASPX code used to implement this example:



The Click event procedure of the Upload button:

Protected Sub btnUpload_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles btnUpload.Click

Dim sizeLimit As Integer = 150000 'Size limit of uploaded file is only 15KB
If fuCustList.HasFile Then
If fuCustList.PostedFile.ContentLength <= sizeLimit Then
Dim path As String = “C:\Uploads\” & fuCustList.FileName
fuCustList.SaveAs(path)
lblMessage.Text = “File uploaded to “ & path
Else
lblMessage.Text = “File exceeds size limit.”
End If
End If
End Sub

The example in the figure above shows the aspx code that declares the file upload control named “fuCustList”, Upload button named “btnUpload” and the Label control named “lblMessage”. Note here that the file upload control doesn’t include an attribute that specifies where the file should be saved on the server. That’s because the file upload control doesn’t automatically save the uploaded file. Instead, you must write code that calls the SaveAs method of this control. The second example in the above figure shows how to write this code.

Before you call the SaveAs method, you should test the HasFile property if indeed there is a selected file by the user. If the user selected a valid file and it was successfully uploaded to the server, the HasFile property will be true. Then, you can use the FileName property to get the name of the selected file, and you can combine the file name with the path where you want the file saved. In this example, the file is stored in C:\Uploads directory.

To show the use of PostedFile.ContentLength property, the event procedure in this figure uses this property to determine the size of the uploaded file. Then, if the value exceeds the limit set by the sizeLimit variable, this file isn’t saved. Instead, an error message is displayed by the Label control in this example.

Properties and Methods of the FileUpload Class

Property & Description

HasFile - If Tue, the user has selected a file to upload
FileName - The name of the file to be uploaded
PostedFile - The HTTPPostedFile object that represents the file that was posted. You can use this object’s ContentLength property to determine the size of the file.

Method & Description

SaveAs(string) - Saves the posted file to the specified path

Thursday, August 13, 2009

Saving an Image in a SQL Server Database

Most of the web applications have a lot of images used in it. These images are usually stored in a web server folder and they are accessed by giving the relative path to the file with respect to the root folder of the website.
.Net being the platform for distributed application now, ASP.Net can be used to store images that are small to be stored in a database like SQL Server 2000 and later versions. For this purpose the SQL Server database provides a data type called “image” which is used to store images in the database.
To access these images stored in the database we will be using the ADO.Net classes. To find out how to insert and retrieve an image in to the SQL Server database, you can create a .aspx page which can have a HTMLInputFile control which is used to select the image file that is to be saved in the database.
You can also create a textbox control in which you can add the image name or some comment or an image id for the image saved. Use a button control to upload the image to the database. Namespaces like System.Data.SqlClient, System.Drawing, System.Data, System.IO, and System.Drawing.Imaging are used in this task.
In the OnClick property of the button you can write the following code to upload an image to the database.

// create a byte[] for the image file that is uploaded
int imagelen = Upload.PostedFile.ContentLength;
byte[] picbyte = new byte[imagelen];
Upload.PostedFile.InputStream.Read (picbyte, 0, imagelen);
// Insert the image and image id into the database
SqlConnection conn = new SqlConnection (@"give the connection string here...");
try
{
conn.Open ();
SqlCommand cmd = new SqlCommand ("insert into ImageTable "
+ "(ImageField, ImageID) values (@pic, @imageid)", conn);
cmd.Parameters.Add ("@pic", picbyte);
cmd.Parameters.Add ("@imageid", lblImageID.Text);
cmd.ExecuteNonQuery ();
}
finally
{
conn.Close ();
}
You can also write the above code in a function and call that function in the OnClick event of the upload button. The code given above performs the following steps in the process of inserting an image into the database.
1. Get the content length of the image that is to be uploaded
2. Create a byte[] to store the image
3. Read the input stream of the posted file
4. Create a connection object
5. Open the connection object
6. Create a command object
7. Add parameters to the command object
8. Execute the sql command using the ExecuteNonQuery method of the command object
9. Close the connection object
To retrieve the image from the SQL Database you can perform the following steps.
1. Create a MemoryStream object. The code can be something like,
MemoryStream mstream = new MemoryStream ();
2. Create a Connection object
3. Open the connection to the database
4. Create a command object to execute the command to retrieve the image
5. Use the command object’s ExecuteScalar method to retrieve the image
6. Cast the output of the ExecuteScalar method to that of byte[]
byte[] image = (byte[]) command.ExecuteScalar ();
7. Write the stream
mstream.Write (image, 0, image.Length);
8. Create a bitmap object to hold the stream
Bitmap bitmap = new Bitmap (stream);
9. Set the content type to “image/gif”
Response.ContentType = "image/gif";
10. Use the Save method of the bitmap object to output the image to the OutputStream.
bitmap.Save (Response.OutputStream, ImageFormat.Gif);
11. Close the connection
12. Close the stream
mstream.Close();
Using the above steps you can retrieve and display the image from the database to the web page.
You can use these algorithms and take advantage of the “image” data type available in the SQLServer 2000 database to store small images that correspond to a particular record in the table of the database. This method of storing avoids the tedious task of tracking the path of the web folder if the images are stored in a web folder.

Sunday, August 9, 2009

A Website for IT Professionals

I just had a membership in this site http://www.insidetech.com (A Monster Company). In this site you can setup your profile, join groups, read news about IT, search jobs and more. This is a good site and at the same time a good resources for IT Professionals indeed.

Be a member and I'll meet you there.. :-)

Wednesday, August 5, 2009

How to File Copy, Move, and Delete Files in VB.Net Using Windows Functionality

Ever wonder how to copy, move and delete files in VB.Net? Well, in this article I will show you how to do it.

Before, in VB6, we have the FileCopy and Kill statements. FileCopy simply locks up your program until the copy is performed, which makes it pretty difficult to give the user feedback as to what your program is doing. Likewise, the Kill statement banishes a file to a Black Hole with no chance of revival.

Now, in VB.Net, due to the object-oriented methodology, you can easily construct a little class that handles these functions for you. Thus, the EnhancedFileOps class will handle this for you.

Using the EnhancedFileOps Class

The most logical method of designing the EnhancedFileOps class would have been to inherit a new class from the existing File class. Unfortunately, this isn’t possible because the File class is marked as NonInheritable, which means that you cannot create a new class under it. Instead, you should create a base class (which inherits right from System.Object) that does the work.

The API (Application Programming Interface) call that handles both file copying (with Progress Dialog) and moving files to Recycle Bin is called SHFileOperation. It takes as its lone parameter a structure called SHFileOpStruct. The declaration for the function and the structure are shown here:

Private Declare Function SHFileOperation_

Lib “Shell32.dll” Alias “SHFileOperationA” (ByRef _

lpFileOp As SHFILEOPSTRUCT) As Integer

Structure SHFILEOPSTRUCT

Public hwnd As Integer

Public wFunc As Integer

Public pFrom As String

Public pTo As String

Public fFlags As Integer

Public fAnyOperationsAborted As Integer

Public hNameMappings As Integer

Public lpszProgressTitle As Integer

End Structure

There are also a fair amount of private constants declared in the class, which represent constants placed into various fields of the SHFileOpStruct.

Sending a File to the Recycle Bin

To send a file to Recycle Bin, you make the API call with the wFunc parameter set to FO_DELETE, and the fFlags parameter set to FOF_ALLOWUNDO, as shown here:

Public Function SendToRecycleBin() As Boolean

Dim sOP As New SHFILEOPSTRUCT()

With sOP

.hwnd = FhWnd.ToInt32

.wFunc = FO_DELETE

.pFrom = FFilename & Chr(0) & Chr(0)

.fFlags = FOF_ALLOWUNDO

End With

Return(SHFileOperation(sOP) = 0)

End Function

Note that the pFrom parameter requires termination in two nulls, written as chr(0) in VB-speak. The reason for this is that the SHFileOperation API call can actually work on more than one file at a time. To process multiple files, you fill the pFrom parameter with each filename separated by single nulls, and then you end the whole file list with two nulls. My example class does not take advantage of the multiple file functionality, but it would be easy enough to add in.

Take special note of the last line in the function, as there are a few different little tricks going on there. The first is that VB.Net functions can return their value by using the special keyword Return. Older versions of VB required assigning a value to a variable whose name was the function name (this was a big pain when you decided to change the function name but forgot to change the result assignment at the bottom).

The second little trick is a programmer’s preference that we can use to compress the code into fewer lines. The last line of code is exactly equivalent to the following statement block:

iResult = SHFileOperation(sOP)

If iResult = 0 Then

Return True

Else

Return False

End If

This block is a bit easier to read, perhaps, but it takes six lines of code, whereas the replacement takes a single line. The trick here is to note that (SHFileOperation(sOP) = 0) is itself a Boolean expression---that is, it has a value of True or False. If the SHFileOperation API call returns 0, then the expression is true. If the API call returns non-zero, then the expression is false. Instead of writing all that out, we find it easier to compress it on one line. We call the function, compare the result to 0, and return the result of that comparison as the result of my SendToRecycleBin function.

Copying or Moving a File

Copying (or moving) a file using the API call is equally simple. In addition to the pFrom parameter that specifies the source, you must also fill in the pTo parameter, which gives the destination. This is usually a folder name, as shown here:

Private Function InternalCopy(ByVal cDestination _

As String, ByVal bMove As Boolean) As Boolean

Dim sOP As New SHFILEOPSTRUCT()

With sOP

.hwnd = FhWnd.ToInt32

If bMove Then

.wFunc = FO_MOVE

Else

.wFunc = FO_COPY

End If

.pFrom = FFilename & Chr(0) & Chr(0)

.pTo = cDestination & Chr(0) & Chr(0)

.fFlags = FOF_SIMPLEPROGRESS Or _

FOF_FILESONLY Or FOF_NOCONFIRMMKDIR

End With

Return (SHFileOperation(sOP) = 0)

End Function

We made this function a private function because it handles both the moving and copying of large files, based on the second function parameter. We then created easy-to-read methods named CopyWithProgress and MoveWithProgress that in turn call this private function.

The function itself simply sets up the API structure and makes the call. Note the FOF_SIMPLEPROGRESS constant as part of the fFlags parameter---that’s what displays the progress dialog when large files are copied.

The example application allows you to pick a file, which it copies to hard coded folder C:\tempvb when a button is clicked. Select a large file (100MB files are pretty commonplace these days on many hard drives) to make sure you see the progress dialog in action. The second button on the form deletes this newly copied file by placing it in the Recycle Bin.

I want to give thanks to Matt Tagliaferri for the explanation and samples.