Thursday, July 28, 2011

BlogEngine.NET open source projects for .NET, great learning source for developers

There are few open source projects available which help to learn more in creating blogs, portals,
intranet site and e - commerce also.
 
some of them are :
 

BlogEngine.NET

blogengine

URL: http://dotnetblogengine.net
Source Code: Grab the source code here
Project Description
BlogEngine.NET may be the simplest and most light weight ASP.NET blog at the moment,
but still full featured. Here are some of the features:

- Multi-author support
- Pingbacks and trackbacks
- Event based for plug-in writers
- Theming directly in master pages and user controls
- Gravatar and coComments implemented
- Live preview on commenting
- Comment moderation
- BlogML import/export
- Extension model
- Code syntax highlighting
- Mono support
- Full editing and creation of pages that are not posts
- Extended search capabilities
- Tag cloud
- Self updating blogroll
- Runs entirely on XML or SQL Server. Your choice.

YetAnotherForum

yetanotherjpg
YAF is a Open Source discussion forum or bulletin board system for web sites running
ASP.NET. The latest production version runs on ASP.NET v2.0 with a Microsoft SQL
Server backend.

URL: http://www.yetanotherforum.net/
Source Code: Grab the source code here

DotNetNuke

dotnetnuke
DotNetNuke is an open source web application framework ideal for creating, deploying and
managing interactive web, intranet, and extranet sites securely.

URL: http://www.dotnetnuke.com
Source Code: Grab the source code here

MojoPortal

mojoportal

URL: http://www.mojoportal.com/
Source Code: Grab the source code here

nopCommerce

nopcommerce

Running on C# nopCommerce is a fully customizable shopping cart. It's stable and highly
usable. nopCommerce is a open source e-commerce solution that is ASP.NET 3.5 based
with a MS SQL 2005 backend database.

URL: http://www.nopcommerce.com/
Source Code: Grab the source code here

 


 

Tuesday, July 26, 2011

progress Bar in swing

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class SplashScreen extends JWindow
{
private static JProgressBar progressBar = new JProgressBar();
private static SplashScreen execute;
private static int count;
private static Timer timer1;
public SplashScreen()
{

setLayout(null);
JPanel panel = new JPanel();
panel.setBorder(new javax.swing.border.EtchedBorder());
panel.setBackground(Color.red);
panel.setBounds(10,10,348,150);
panel.setLayout(null);

add(panel);
JLabel label = new JLabel("Hello World!");
label.setFont(new Font("Verdana",Font.BOLD,14));
label.setBounds(85,25,280,30);
panel.add(label);

progressBar.setMaximum(50);
progressBar.setBounds(55, 180, 250, 15);

add(progressBar);
loadProgressBar();
setSize(375,300);
setLocationRelativeTo(null);
setVisible(true);
}
public void loadProgressBar()
{
ActionListener al = new ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
count++;
progressBar.setValue(count);
if (count == 51){
timer1.stop();
execute.setVisible(false);

//load the rest of your application

}
}};
timer1 = new Timer(300, al);
timer1.start();
}

public static void main (String args[]){
execute = new SplashScreen();
}
}

Wednesday, July 20, 2011

Importance of Enumerations

Enumerations are simple value types that allow developers to choose from a list of constants.

Behind the scenes, an enumeration is just an ordinary integral number where every value has

a special meaning as a constant. However, because you refer to enumeration values using their

names, you don’t need to worry about forgetting a hard-coded number, or using an invalid

value.

To define an enumeration, you use the block structure shown here:

public enum FavoriteColors

{

Red,

Blue,

Yellow,

White

}

This example creates an enumeration named FavoriteColors with three possible values:

Red, Blue, and Yellow.

Once you’ve defined an enumeration, you can assign and manipulate enumeration values

like any other variable. When you assign a value to an enumeration, you use one of the predefined

named constants. Here’s how it works:

// You create an enumeration like an ordinary variable.

FavoriteColors buttonColor;

// You assign and inspect enumerations using a property-like syntax.

buttonColor = FavoriteColors.Red;

In some cases, you need to combine more than one value from an enumeration at once.

To allow this, you need to decorate your enumeration with the Flags attribute, as shown here:

[Flags]

public enum AccessRights

{

Read = 0x01,

Write = 0x02,

Shared = 0x04,

}

This allows code like this, which combines values using a bitwise or operator:

AccessRights rights = AccessRights.Read | AccessRights.Write | AccessRights.Shared;
You can test to see if a single value is present using bitwise arithmetic with the & operator

to filter out what you’re interested in:

if ((rights & AccessRights.Write) == AccessRights.Write)

{

// Write is one of the values.

}

Enumerations are particularly important in user-interface programming, which often has

specific constants and other information you need to use but shouldn’t hard-code. For example,

when you set the color, alignment, or border style of a button, you use a value from the appropriate

enumeration.

 

The Roles of Classes in Object-oriented programming

It’s important to remember that although all classes are created in more or less the same way

in your code, they can serve different logical roles. Here are the three most common examples:

Classes can model real-world entities. For example, many introductory books teach

object-oriented programming using a Customer object or an Invoice object. These

objects allow you to manipulate data, and they directly correspond to an actual thing in

the real world.

Classes can serve as useful programming abstractions. For example, you might use a

Rectangle class to store width and height information, a FileBuffer class to represent a

segment of binary information from a file, or a WinMessage class to hold information

about a Windows message. These classes don’t need to correspond to tangible objects;

they are just a useful way to shuffle around related bits of information and functionality

in your code. Arguably, this is the most common type of class.

Classes can collect related functions. Some classes are just a collection of static methods

that you can use without needing to create an object instance. These helper classes are the

equivalent of a library of related functions, and might have names like GraphicsManipulator

or FileManagement. In some cases, a helper class is just a sloppy way to organize code

and represents a problem that should really be broken down into related objects. In

other cases, it’s a useful way to create a repository of simple routines that can be used in

a variety of ways.

Understanding the different roles of classes is crucial to being able to master object-oriented

development. When you create a class, you should decide how it fits into your grand development

plan, and make sure that you aren’t giving it more than one type of role. The more vague a

class is, the more it resembles a traditional block of code from a non-object-oriented program.

 

check directory Exists in Ftp Server

 

public bool FtpDirectoryExists(string directoryPath, string ftpUser, string ftpPassword)

        {

            bool IsExists = true;

            try

            {

                FtpWebRequest request = (FtpWebRequest)WebRequest.Create(directoryPath);

                request.Credentials = new NetworkCredential(ftpUser, ftpPassword);

                request.Method = WebRequestMethods.Ftp.PrintWorkingDirectory;

 

                FtpWebResponse response = (FtpWebResponse)request.GetResponse();

            }

            catch (WebException ex)

            {

                IsExists = false;

            }

            return IsExists;

        }

 

I have called this method as:
bool result = FtpActions.Default.FtpDirectoryExists( "ftp://domain.com/test",
                                                    txtUsername.Text, txtPassword.Text);

Sunday, July 17, 2011

check string exists in the enum and convert string to an Enum

/// <summary>

/// File Type Enum - The extensions that our application

/// support to work.. check at the time of work with the

/// file.. e.g. read the file and save to database etc.

/// </summary>

 

enum FileTypes

{

     BMP ,

     JPG ,

     JPEG,

     GIF,

    TIFF

}

 

string fileExtension = Path.GetExtension(filePath).ToUpper();

       

//check string exists in the enum.. it will match the case also..

if (Enum.IsDefined(typeof(FileTypes),fileExtension.Trim('.')))

{

    //convert string to enum

    FileTypes  c = (FileTypes) Enum.Parse(typeof(FileTypes), "MOV", true);

}

 

Note: Enum.IsDefined() doesn't offer the ignoreCase parameter. If you don't

know whether the casing is right, it seems the only way to do the conversion is using

the Parse method and catching the ArgumentException.

Saturday, July 9, 2011

Get textbox server control value using jquery in asp.net

Retrieve the server control id in the java script (jQuery code) and do as usual
jQuery code for getting the value at the ASPx page.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="scripts/jquery-1.6.1.min.js" type="text/javascript"></script>
    <script type = "text/javascript">
        $(document).ready(function () {

            $("#<%= btnSend.ClientID %>").click(function () {
                alert($("#<%= txtInfo.ClientID %>").val());
                return true;
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style=" margin : 0px auto">
        <asp:TextBox ID="txtInfo" runat="server"></asp:TextBox>
        <
asp:Button ID="btnSend"  runat="server" Text="Send" />
    </div>
    </form>
</body>
</html>