Color odd and even div alternatively with different color

I had a situation where I need to have an alternate background color for the rows inside a parent div. Sample code is shown below

<div class="content-body-notification content-body  ">
<div class="user-row">
1
</div>
<div class="user-row">
2
</div>
<div class="user-row">
3
</div>
<div class="user-row">
4
</div>
</div>

So now we are going to give different background color to odd and even user-row rows as shown below


.content-body .user-row:nth-child(odd) {
    background: #eeeff2;
}
.content-body .user-row:nth-child(even) {
    background: #f8f8fa;
}

and we get output same as diagram shown below:

Advertisements

Preview Image before it is uploaded

Today we are going to learn about Image preview before it is uploaded.

In your php file, you have code as shown below:

<form id="form1" runat="server">
        <input type='file' id="uploadFile" />
        <img id="imagePreview" src="#" alt="your image" />

<script type="text/javascript" src="js/imagePreview.js"></script>
</form>

Include your script file in your header or footer, and you have js file with the name imagePreview as shown below:

$(function() {
    $("#uploadFile").on("change", function()
    {


        $( "#imagePreview" ).addClass( "giveImgStyle" );
        var files = !!this.files ? this.files : [];
        if (!files.length || !window.FileReader) return; // no file selected, or no FileReader support

        if (/^image/.test( files[0].type)){ // only image file
            var reader = new FileReader(); // instance of the FileReader
            reader.readAsDataURL(files[0]); // read the local file

            reader.onloadend = function(){ // set image data as background of div
                $("#imagePreview").css("background-image", "url("+this.result+")");
            }
        }
        else{
            alert('Please Select Image');
        }
    });
});


Then in your style sheet, add the style for giveImgStyle


.giveImgStyle{
    width: 180px;
    height: 180px;
    background-position: center center;
    background-size: cover;
    display: inline-block;
}

Then you are done. you get imagepreview as shown below

imagepreview

Send mail in C#

Here is the code snippet which allows you to send mail in c#

public void SendEmail()
{
MailMessage message = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
string msg = string.Empty;
try
{
MailAddress fromAddress = new MailAddress(“Your Email ID”, “Email Received”);
message.From = fromAddress;
message.To.Add(“Recepient email id”);
message.IsBodyHtml = true;

message.Bcc.Add(“Carbon copy email id”);
message.Subject = “Contact us info”;
message.IsBodyHtml = true;
message.Body = “ Hello!!!! ” + “Overseas Administrator” + “
” + “Contact Us information” + “

” + “Name: ” + txtyourname.Text + “
” + “Company Name: ” + txtemail.Text + “
” + “Email: ” + txtyoursubject.Text + “
” + “Message: ” + txtyoursubject.Text;
smtpClient.Host = “mail.omnis.com”; // We use gmail as our smtp client
smtpClient.Port = 587;
smtpClient.EnableSsl = true;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential(“your gmail id”, “gmail password”);

smtpClient.Send(message);

}
catch (Exception ex)
{
msg = ex.Message;
}

}