Tuesday, March 11, 2014

How do you validate email

protected void btnValidate_Click(object sender, EventArgs e)
{
bool isEmail = Regex.IsMatch(txtEmail.Text.Trim(), @"\A(?:[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[A-Za-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)\Z");
if (!isEmail)
{
   lblerrormsg.Text = "Enter Valid Email ID..";
   lblerrormsg.ForeColor = System.Drawing.Color.Red;
   return;
}
else
{
   lblerrormsg.Text = "Valid Email";
   lblerrormsg.ForeColor = System.Drawing.Color.Green;
}
}

Wednesday, January 22, 2014

What is master page?

Master Page is used in web application
We can say master page as a template for the other pages in our project.
For creating a constant look and feel for all our pages in web application.
It acts as a placeholder for the other pages or content.
If a user makes a request to a webpage it merges with masterpage and will provide the output .

What is publisher subscriber model? Any design pattern can be implemented for it?

It is also called as Observer design pattern.
Windows Communication Foundation (WCF) is the best exampled for this model.
The user can publish a Service and it can be consumed by many clients at the end point.
The Publisher gives the data to the clients who have subscribed to their methods.

What is Nuget?

It is Visual Studio extension and a open source project
By using Nuget we can easily add,update and remove libraries in Visual Studio Projects.
When you add or remove a library it copies/removes necessary files to your application.
It is a quick way to add reference to our application.

What is difference between a.equals(b) and a==b?

“==” --> It compares reference
"Equals" --> It compares object by VALUE.