connectseekers.com

Sunday, 10 April 2016

Sign Up Form For Newsletter In Asp.Net Using C# and Css3

4/10/2016 - By Pranav Singh 0


This article will show you how you can create  a news letter subscription for your website using css, asp.net in your asp.net application.

So for this article firsat we will create a new asp.net application and add the below code in your asp.net application.


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

<!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>Sign Up Form For Newsletter In Asp.Net Using C# and Css3</title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div class="header">
        <p>
            Sign Up For Newsletter</p>
    </div>
    <div class="description">
        <p>
            Sign Up Form For Newsletter In Asp.Net Using C# and Css3
        </p>
    </div>
    <div class="input">
        <input class="button" id="email" name="email" placeholder="name@example.com" runat="server" />
        <asp:Button ID="submit" runat="server" Text="SIGN UP" CssClass="button"
            onclick="submit_Click" />
    </div>
    </form>
</body>
</html>

In above code I have added the css style sheet to display the stylish form to add email id.

  
 <link href="css/style.css" rel="stylesheet" type="text/css" />


Now check he below code to save the data in DB.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
namespace NewsLetter
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void submit_Click(object sender, EventArgs e)
        {
            try
            {
                SqlConnection con = new SqlConnection("<---Your connection string ---->");
                string query = "Insert into Sucscription(EmailId) values('" + email.Value + "');";
                SqlDataAdapter da = new SqlDataAdapter(query, con);
                da.SelectCommand.ExecuteNonQuery();
                lblMessage.Text = "Subscription sone successfully.";
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message.ToString();
            }

        }
    }
}

 In above query Sucscription is a table in which we will save the data. Now we have done. Run the application to check the output.



Tags: , ,
About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com
Email Id : contact@aspdotnet-pools.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top