Archive for the ‘General’ Category

i was reading a book head first design pattern, actually read that book many times, an excellent book. Sharing my details idea singleton design patter.

class diagram of Singleton design pattern

a singleton class is look like that
public class Singleton
private static Singleton UniqueInstance; //variable to hold one instance of the class Singleton
private Singleton(){}
public static Singleton getInstance()
if(UniqueInstance==null)UniqueInstance=new Singleton();
return UniqueInstance;
here the Singleton class constructor is private and it has only one static method to get it, that ensures that this class has only one instance, and provide a global point to access it.

Now think for multi threading…
what will happen??? suppose you have 2 threads, so 2 different instance of the object will be created.


Read Full Post »

Keep Popup Window always on top

At the time of web page development i got a very bad problem, popup window is not coming always on the top of the page. But this is my client requirment i have to do it. This was really a bad experiance. After searching i got the and sharing with all. Just add this in your popup page BODY tag

<BODY onBlur=”window.focus();”>

Read Full Post »

i written a simple code

SmtpClient smtp = new SmtpClient(“localhost”);
smtp.Send(“from@testserver.com”, “to@testrserver.com”, “Test mail subject”, “Test mail body”);

but got exception “Mailbox unavailable. The server response was: 5.7.1 Unable to relay to@servername.com.”.  Problem is not in the code problem is in the configuration of localhost. It considers itself being used as a mail relay and by default it does not allow anyone to do that. It is easy to solve.

1. Go to “Default SMTP Virtual Server” in IIS and then go to properties

2. Select tab “Access”

3. Add ip of localhost “”


Read Full Post »

Login failed for user Machinename\ASPNET

I faced that problem when i run my application from localhost. Got the solution

Go to command prompt and write these commands. Take care of the spelling database name and tablename.

cd C:Program FilesMicrosoft SQL Server80ToolsBinn

osql -E -S localhost -Q “sp_grantlogin ‘MYCOMPUTERASPNET'”

osql -E -S localhost -d DatabaseName -Q “sp_grantdbaccess ‘MYCOMPUTERASPNET'”

osql -E -S localhost -d DatabaseName -Q “sp_addrolemember ‘db_owner’, ‘MYCOMPUTERASPNET'”

–Don’t forget to change you computer name and database name

Read Full Post »

Components of Ajax

Ajax components are:

1. Javascript:  Scripting language that commonly hosted in a browser to add interactively to HTML pages

2. DOM (Document Object Model): DOM is leveraged to efficiently redraw portions og hte pages.

3. CSS (Cascading Style Sheets) : modify the exterior of the user interface interactively

4. XMLHttpRequest: opposed to performing a full-page refresh or postback

Read Full Post »

I wonder today when I see that I
have forgotten that vary simple things of regular expression.
I was good in regular expression at university time. Time goes
no practices and brain betrayed and forgotten. Strange!!

I searched to remember again how
regular expression can be written; at least Google did not betrayed got a nice site
where they told very basic of Regular Expression. Now I can remember everything.
This is a nice site to know very basic of regular expression

> Just this table is enough I think

^ Start of a string.
$ End of a string.
. Any character (except n newline)
{…} Explicit quantifier notation.
[…] Explicit set of characters to match.
(…) Logical grouping of part of an expression.
* 0 or more of previous expression.
+ 1 or more of previous expression.
? 0 or 1 of previous expression; also forces minimal matching when an expression might
match several strings within a search string.
Preceding one of the above, it makes it a literal instead of a special character.
Preceding a special matching character, see below.
w matches any word character, equivalent to [a-zA-Z0-9]
W Matches any non word character, equivalent to [^a-zA-Z0-9].
s matches any white space character, equivalent to [fnrv]
S matches any non-white space characters, equivalent to [^fnrv]
d matches any decimal digits, equivalent to [0-9]
D matches any non-digit characters, equivalent to [^0-9]
a Matches a bell (alarm) u0007.
b Matches a backspace u0008 if in a [] character class; otherwise, see the note following
this table.
t Matches a tab u0009.
r Matches a carriage return u000D.
v Matches a vertical tab u000B.
f Matches a form feed u000C.
n Matches a new line u000A.
e Matches an escape u001B
$number Substitutes the last substring matched by group number (decimal).
${name} Substitutes the last substring matched by a (? ) group.
$$ Substitutes a single “$” literal.
$& Substitutes a copy of the entire match itself.
$` Substitutes all the text of the input string before the match.
$’ Substitutes all the text of the input string after the match.
$+ Substitutes the last group captured.
$_ Substitutes the entire input string.
(?(expression)yes|no) Matches yes part if expression matches and no part will be omitted.

Read Full Post »

guideline for programmer


Read Full Post »

Older Posts »