Wednesday, June 25, 2014

Color conventions in c# of to and fro conversion(HTML to C# and C# to HTML)

Introduction

In this article I explain how to convert the HTML colors to the c# colors because in c# we have only limited number of colors like example red, green, blue etc…. If you want to display the color some shaded color and RGB color mixing process you can use this methods to overcome this functionalists

Write the below code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;



Read More »

Tuesday, June 24, 2014

Sending Mail from Asp.Net c# with Attachment

Introduction

This post will explain you how to sending the mail from the asp.net along with file attachment

Note:- You can send even though you company having Gmail access

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;


Read More »

Sending Mail from Asp.Net c#

Introduction

This post will explain you how to sending the mail from the asp.net

Note:- You can send even though you company having Gmail access 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;






namespace SampleTestingCodes
{
    public partial class SendingMailFromAsp : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SendMail();
        }
        protected void SendMail()
        {
            // Gmail Address from where you send the mail
            var fromAddress = "gmail@gmail.com";
            // any address where the email will be sending
            var toAddress = txtemailid.Text.ToString();
            //Password of your gmail address
            const string fromPassword = "*****************************";
            // Passing the values and make a email formate to display
            string subject = txtsubject.Text.ToString();
            string body = "From: " + txtyourname.Text + "\n";
            body += "Email: " + txtemailid.Text + "\n";
            body += "Subject: " + txtsubject.Text + "\n";
            body += "Question: \n" + txtbody.Text + "\n";
            // smtp settings
            var smtp = new System.Net.Mail.SmtpClient();
            {
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                smtp.EnableSsl = true;
                smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
                smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
                smtp.Timeout = 20000;
            }
                  using (var message = new MailMessage(fromAddress, toAddress)
                {
                    Subject = subject,
                    IsBodyHtml = true,
                    Body = body


                })
                {
                    smtp.Send(message);
                }
                // Passing values to smtp object
                //smtp.Send(fromAddress, toAddress, subject, body);
        }
    }
}



Out put will look like
From: lokehs
Email: lannam@technobrainltd.com
Subject: hi
Question:
gg



Read More »

Wednesday, June 18, 2014

Examples of LINQ and LABDMA expression examples, functions and usages for collection types

Write the below code and execute

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LinqAndLambdaExpressions.aspx.cs"
    Inherits="SampleTestingCodes.LinqAndLambdaExpressions" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>

Read More »

Sunday, June 15, 2014

How to bind the Asp.Net grid with selected data using Lambda Expressions

Write the bellow code for and execute

In Design Side

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LinqAndLambdaExpressions.aspx.cs"
    Inherits="SampleTestingCodes.LinqAndLambdaExpressions" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>

Read More »