Pages

Thursday, October 21, 2010

Styling 'alt' attribute of img tag

Ever felt a need to change color, height on any style of alt tag ??

Before going further, let me clear you one thing. alt is 'content' not 'presentation'.As such it cannot be styled simply.We need to apply little bit of hack in it.

So,  Lets Code...

Put a wrapper around the img tag in which you are using alt attribute and style that wrapper. We can use <style> or <div> tag to wrap the img tag.


Wednesday, September 29, 2010

Send email from yahoo, gmail or your smtp server through asp.net

To send a email from asp.net you need to follow these steps...

We use System.Net.Mail namespace to send email. Without going into details, lets have a simple working code to send emails through asp.net via two most popular smtp mail servers.

Gmail:


try
{
MailMessage mail = new MailMessage(); //using System.Net.Mail namespace
mail.To.Add("xyz@yahoo.com"); //Enter reciever's email address
mail.From = new MailAddress("abc@gmail.com"); //Enter sender's email address
mail.Subject = "Testing mail...";
mail.Body = @"Lets-code ! Lets-code to make it simpler";
mail.IsBodyHtml = true; //Body of mail supports html tags
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("abc@gmail.com", "pwd");
// Your gmail username and password
smtp.EnableSsl = true; //Gmail uses a encrypted connection
smtp.Send(mail);
Response.Write("Mail Sent Successfully");
}

catch(Exception ex)
{
Response.Write(ex.Message);
}



Sunday, September 26, 2010

Syntax Highlighter - post code snippets on web


Need to display code in your blog or website like the html code given below ??


<html>
<body>
<div> Hi, I am html code </div>
</body>
</html>


Or a C# code

using system;
protected string func()
{
Response.WriteLine("Hi from C# code");
}



Pretty nice formatting and show-off . Isn't it ? You too can do this in some simple steps.
Just follow this simple copy-paste mechanism step by step.



Monday, September 20, 2010

Facebook Comments in your blogger

So, you too want your users to comment from facebook id ?

Lets code...

Below is a tutorial to integrate Facebook Comment Plugin to your blogspot blog.

Follow these simple steps and let Facebook Comment Plugin dance on your finger tips.


Step 1: Create a facebook application first.

Dont worry, you need not to code for this. Just go to this page Create Facebook Application.
Verify your facebook account by credit card or mobile phone.
(Though this whole verification thing has a bug. But hope, facebook will recover from it soon )

Then click + Set Up New Application
Enter your application name (type your blog name or anything you want)
Check I agree and click Create Application

Congratulations, you have just created a facebook application.

After creating application, go to 'Edit Settings' .
Go for 'Website' tab at left tabs-list.
In Site URL, Enter url of your blog ( as lets-code.blogspot.com)
Click on SAVE CHANGES.



Copy the app-id (circled in the picture below)