Posts By Category

Posts By Date

Resources:

C# Books
ASP.NET Books DotNet4All








If you like to support this site, feel free to make a donation to support improvements.

Thank you!

Monetize Your Blog

A recent web application I just finished

Over the past month, I've been working on a real estate site for one of my clients. The site is made in Arabic, and was written in C# ASP.NET from grounds up. It allows adding, removing and modifying lands for sale, and acts like an ASP.NET template kit for any similar content management system with an Admin area. The site is now live and can be seen by following this link: http://www.hishamkhraisat.com/

Continued...

A quick tool to convert free CSS documents from Left-To-Right into Right-To-Left templates,

I was working on an Arabic language site for one of my clients, and needed to adapt one of the free CSS designs out there on the web, however my problem was that the CSS design was written for Latin based languages, or more accurately for Left-To-Right languages, and I needed a quick way to convert it to work for the Arabic language, which is a Right-To-Left language. So while I was just about to put on my heavy armored CSS gear, I googled around a little and found this very cool tool published by

Continued...

Automating forms authentication in ASP.NET

I was working on a screen scrapping project, and was looking for away to automate the login form for an ASP.NET web page. Googling around, I found a very helpful article written by Scott Allen that lists the steps necessary to automate login using HttpWebRequest.

Continued...

Alternative way to string.split using Regular Expressions

The other day I was working on a YoutTube auto uploader software for one of my clients, and I needed to prevent passing along single character tags to the uploader engine. If you are familiar with the rules of the tag field when uploading videos to YouTube, you know that tags must be 2 or more characters long.

Continued...

Email Followup System

This is a proect I worked on recently, it is a simple customer email followup system done in ASP.NET.

You can add/delete/update customers. The app allows you to send emails to each customer, and records the last contact date.

You can also add/delete/update predefined/defaul email text, then use them to quickly compose email letters.

You can see a demo for the app here:

Customer Management Web App

 

Continued...

Removing Items From a List Control (Visual C#)

I was writing a Windows Application and I had a very simple need: Remove all Selected items from a ListBox control. If you have tried to simple use code like the one below:

Continued...

A C# Algorithm to calculate the best way to cut small pieces of paper out of a larger piece

This is a project I worked on last year. It is an algorithm to to show the best way to cut small pieces of paper out of a larger piece. I wrote the algorithm in C# then used System.Drawing.Imaging to to demo its output on an ASP.NET page.

You can see the demo page here

Here were the project's requirements:

Continued...

Cann't open any more Internet Explorer windows?

If you are a RAM hungry user like me, leave many windows, apps and virtual machines open on your Vista System, you have probably ran into a situation where you could not open any more windows… even though your system has plenty of RAM… (2 GB in my case J ) you would still get to a point where you are not even able to get the context menu when you

Continued...

ASP.NET GridView

When you bind a GridView to an ObjectSource in ASP.NET, sometimes, you don't want to display all of the columns returned from the ObjectSource DataTable, but if you use a GridView and let it autmatically generate the columns, it becomes not a striaght forward deal to hide the individual selected columns. Here is a way to do that:

Simply catch the RowDataBound event on the GridView and if you know the index of the column to hide, just use it as follows:

Continued...

A way to achieve secondary for DataTable in C#

I recently stumbled across the following C# code that allows sorting and filtering rows in a DataTable using DataTable.Select method:

http://authors.aspalliance.com/olson/methods/FilterSortData.aspx

However, what I needed was to sort on a primary column, then if DataRows had the same value for the primary column, perform a secondary sort based on another secondary column.

Continued...

How to FTP using Windows Explorer!

Not many people know that you can use your simple Windows Explorer with as an FTP client to upload and download files... Well maybe I'm the only one who doesn't know, but it surely made my day today when I found out.

The nice thing about using Windows Explorer as an FTP client is that you get all the drag and drop features that come with it, while uploading and downloading remotely, and no need to buy an FTP client software.

Continued...

Upload movies and convert into FLV in Flash

I recently finished working on a YouTube-like project where you can upload any video file (mpeg, avi...etc.) and automatically convert it into FLV then display a link to the converted video into an online flash movie player.

The project involved using the free open source utility ffmpeg along with some other utilities from around the net. In addition it shows upload progress as the user is uploading the movie file.

Continued...

Using HttpRuntime to get the web application absolute path

We all know in ASP.NET, to get the absolute path from the relative path, you can prefix your relative path with the Tilde character as follows:

MyHyperLink.NavigateUrl = "~/Catalog/ASP/Products";

Continued...

Writing SQL query for MS Access

I'm currently organizing an MS Access database and setting up some SQL queries that export data into CSV files for Yahoo Store. One of the things I had to do was to create fields in the CSV file that are compound of other existing fields in the database, and some that even depended on the existence of other physical fields in the Access database.

Continued...

Wild card % does not work in MS Access for LIKE SQL statement

Using LIKE statement in an SQL query requires specifying wild cards in the search pattern. In C# .NET, the wild card is %, however if you are building your SQL query directly from MS Access, I found out you need to use the asterisk (*) instead of (%) wild card to achieve the same result.

Continued...

Use Intermittent Sleeping (small increments) instead of one long Thread.Sleep for a quicker, more responsive multi-threaded application

We all had to use Thread.Sleep at one point or another to wait on an event to happen, or to satisfy a configuration setting during cyclic calculations or a processing. But is your worker thread sleeping too much? Does it feel sometimes that your code sleeps in the wrong time

Continued...

A list of all the free utilities & user controls in C# & ASP.NET on www.mycsharpcorner.com ...

Here is a list of all the free utlities & user controls developed and published on http://www.mycsharpcorner.com . More will be coming soon, but for now, here is a quick list:

Social Links User Control in ASP.NET - Read the related article

Continued...

How I handled 301 redirects to avoid duplicates in my SE ratings

If you have done SEO work, you know that Search Engines would penalize my site if both http://www.mycsharpcorner.com and http://mycsharpcorner.com/ requests returned a 200 OK code in the HTTP header. Why? Because from a Search Engine's spider point of view, there are 2 sites, one with the www prefix, and one without it, yet in reality they the same site. So what’s wrong if the Search Engine thinks

Continued...

How to calculate one column from another in Excel

Well, this is not a programming tip; it is more of a general Excel tip from a recent assignment I had for one of my clients. I had an Excel document with two columns; one needed be calculated from the other based on a percentage formula, so:

SalePriceColumn=OriginalPriceColumn + 15% extra

Continued...

A free user control to hold the social links icons in ASP.NET

Do you like the social links bar on top of this article? Do you hate it? In today's internet blog, you almost never miss seeing a "Digg It", a "Kick it", a "Ridd It" a Furl it, burl it...or squirrel it... link or icon at the end of each article you read in someone's blog. Well, regardless of the opinions people might have about this phenomenon, if you are an ASP.NET programmer like me, your concern would probably be over how to construct the "social-butterfly" user control, rather than

Continued...

Real Time Traffic Tracker for your site

It's been three weeks since I started this project, and I've been curious to see how the site is being used, and how many people are visiting... what are they reading...etc. So I started a small little project on the side, called the Traffic Tracker.

Continued...

Using StreamReader & StreamWriter to insert a text at a given line number

System.IO.StreamWriter allows you to write text to a file easily if you are creating the file and know the order of the lines. However, what if you are trying to edit a file? For example, you need to insert a text at a specified line number in an existing text file. Say you have a text file that contains: Continued...


Programmatically send emails using Google mail server and System.Net.Mail.SmtpClient

Did you know you can use your gmail mail server to send and receive emails programmatically for free?

Continued...

How to write C# code to check if Google’s bot crawled your ASP.NET site

If you are monetizing your site with AdSense, one important piece of traffic you want to monitor, is when Google spider visits your site to crawl it. Or maybe you want to know if the Google robot ever comes to visit or not, and if it does, when, and how often does it crawl your site? Doing this in ASP.NET is very

Continued...

How to close another process's main window from a C# App without invoking Native Win32 code

Back in the good (or bad :) ) days of Win32 programming, there was a nice little function named FindWindow. It enabled you to find any window belonging to any process on your system

These days are gone with C# .NET, well... not quite!

If you have been looking for an alternative to FindWindow, Read along. There are two alternatives, the first involves invoking FindWindow directly from the Native Win32 DLL API, but that takes us back to the old days.

Continued...

System.Windows.Forms.Timer does not work for Console Applications because you need an event loop, so you need to use System.Threading to implement your own timer with an event loop, here is how...

In Console Applications, you don't have an event message loop like in a Windows Application project, hence, so you can't use the System.Windows.Forms.Timer object since it depends on Windows Message loop to fire its tick events.

Continued...

Fun with C# Timers… Flash a Windows Control to draw attention to it's invalid data

 Download

One common Windows Application development task is to validate a TextBox or a Windows Control against a certain value, or whether the user has entered a value at all before hitting the submit/Ok button, then display some kind of an error.

Continued...

You can spawn the regedit.exe command utility to simply mimic it's behavior in your C# application, here is how...

One of my clients needed to run a script on a user machine every time the user logged in. The script would import some registry keys and settings that customize certain parts in Windows for their client.

My task was to write the script. Well, my first thought was to write a text parser for their .reg file, then using the .NET Registry classes to import all the keys into the registry one by one.

Continued...

Track your visitors IP & Host Info, but make sure to catch any exceptions

In my previous article, How to track visitors to your site in ASP.NET & C#, I discussed how you can log the Host Info for each page visitor on your site using Dns.GetHostByAddress function.

One thing I did not stress out was the need to catch all exceptions from that method call. There are cases when this call:

Continued...

Code to log the IP address & DNS name for visitors to each page

Once you have published a site in ASP.NET, you'd like to know who are your visitors. One way is to check your event log on the host server. Another option is to write your own code. You'd basically like to log the IP address, and DNS name for the visitor, and it would be nice to know which page they are visiting.

To log the ip address using ASP.NET, you can call:

Continued...

How to parse a webpage in C#? Simple text parsing in C# using GetStringInBetween, GetStringBetween

One common requirement especially when doing screen scrapping is to find strings contained between html tags, or other strings. Regular Expressions provide a powerful way to do so, but are initially intimidating for a beginner programmer. Here is an alternative solution to finding a string between two other strings that uses simple string manipulation in C#, without Regular Expressions:

Usage:

Continued...

How to parse a webpage in C#? Text Parsing in C#

We all know how to remove/replace a string in C#, for example:

string myString = "Yousef (programmer) likes to write in C#";

To remove "(programmer)", we can write:

myString = myString.Replace("(programmer)", "");

Continued...

Code to log the IP address & DNS name for visitors to each page

Once you have published a site in ASP.NET, you'd like to know who are your visitors. One way is to check your event log on the host server. Another option is to write your own code. You'd basically like to log the IP address, and DNS name for the visitor, and it would be nice to know which page they are visiting.

To log the ip address using ASP.NET, you can call:

Request.ServerVariables["HTTP_X_FORWARDED_FOR"]

Continued...

Monitor processes as they start and end on your computer, good for catching viruses, spyware, or just simple system diagnoses

Process Logger monitors processes as they start and end on your computer and logs them out. It's very useful if you are suspecting some spy ware or even viruses being on your computer, and want to closely monitor what process starts and stops as soon as it happens. It can also help

Continued...

utilizing GetProcesses in .NET to log start and end times for currenlty running processes on yoru machine

Here is a quick C# script to log the start and end times of running processes on your machine.

The idea is query the currently running processes every x number of seconds utilizing the Process.GetProcesses function in .NET, while maintaining a book for currently running processes each cycle, then if a new process appears (or disappears), you log the result as start and end respectively.

Here is how to get currently running processes on your machine using C#:

Continued...

Use .NET Timers to setup a Clock user control on a Windows Form in C#

Making your own Clock control to display on your Windows Form to display and update the current time up to the second is an easy deal using C# Timers.

Creating The Clock User Control Step By Step

Here is one way to do it:

Continued...

Using a volatile variable to control GUI from a background thread

I was writing this application for a client of mine, and I needed to dsiplay a "Please Wait..." message while disabling access to the the rest of the application controls during a lengthy background process, but at the same time, wanted to show that the application is alive and well.... not frozen, maybe even put a cancel or a stop button to terminate the lengthy process.

Continued...

Difference between ComboBox over RadioButton..

Both controls provide functionality to select from multiple choices, so what's the difference between them? And when to use one over the other?

In short, ComboBox is a more compact GUI control to house multiple choices, so it is more suitable for large number of choices, so all choices can be shown in the same space that is needed by one choice, while RadioButton groups tend to show all the available choices in the web form, or windows form.

Continued...

When to use a Check Box and when to use a Group of Radio Buttons

What's the difference between a check box and a Radion button?

The short answer to this is:

- Check box is used to indicated a boolean value: True or False

- A group of Radio Buttons is used when you have more choices than True or False... say you have a choice like "Maybe"...

So use a group of Radio button when you have multiple choices and you only want to select one and only one choice. Use a Check box when you have only 2 choices, this or that, and no more.

Continued...

Small talk about Object Oriented Programming OOP

Someone asked me how long it will take them to learn C++, then how long will it take to learn OOP concepts, so I thought I share my answer here.

Continued...

Allow Sellers to list their products for sale on the eMarket

I just finished working on an e-Market Web Application using ASP.NET 2.0. The app allows users to sign up for accounts, create a Seller profile and add/remove/modify products for sale.

The e Market allows display and browsing of all products and allows admin to manage users, sellers and products.

You can see a demo of the Web App here:

http://laemarket.firstmortgagenews.com

Continued...

Site Launch

Welcome everyone,

I've been playing with the idea of launching this site for a while now, and today after finding this free ASP.NET blog starter kit written in C#, I finally decided to put it to use. Thanks to Shanku Niyogi for making this kit available.

Continued...

Copyright © 2007 Yousef Mannaa. All material on this site is copyrighted.
Do not publish or reproduce any of this material without written permission from the Author