STEP 1 CREATE PANEL CONTROL
STEP 2 UNDER PANEL CONTROL CREATE ALL FORM AND DESIGN
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="SHOW DATA" Width="157px" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="SEND MAIL" Width="161px" />
<br />
<br />
<br />
<asp:Panel ID="pnlContents" runat="server" style="border-style: ridge;padding:10px;">
<h1>Customer Generate Bill </h1> <br />
<address>Narula Business Center , Near Lokmat Square </address>
<br />
<b>Mobile No. 8411064860</b>
<hr />
<asp:FormView ID="FormView1" runat="server">
<ItemTemplate>
Student Information Details
<br />
<br />
<b>Name of Customer : </b> <asp:Label ID="Label1" runat="server" Text='<%# Eval("name") %>'></asp:Label> <br />
<b>Customer City : </b> <asp:Label ID="Label2" runat="server" Text='<%# Eval("city") %>'></asp:Label> <br />
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</form>
</body>
</html>
=================== C# Coading ========================
using System.Data.SqlClient;
using System.IO;
using System.Net.Mail;
Coding for send button
protected void Button2_Click(object sender, EventArgs e)
{
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter hw = new HtmlTextWriter(sw))
{
pnlContents.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
SmtpClient smtpClient = new SmtpClient("nrsolution4u-student.com", 25);
smtpClient.Credentials = new System.Net.NetworkCredential("contact@nrsolution4u-student.com", "password");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
MailMessage mailMessage = new MailMessage("contact@nrsolution4u-student.com", "nileshimp2015@gmail.com");
mailMessage.Subject = "Domain Testing";
mailMessage.Body = sw.ToString();
mailMessage.IsBodyHtml = true;
smtpClient.Send(mailMessage);
}
}
}
No comments:
Post a Comment