ForgotPassword using telerik controls and asp.net c#
<%@ Page Title="" Language="C#" MasterPageFile="~/PublicWebsites/MainMaster.Master" AutoEventWireup="true" CodeBehind="ForgotPassword.aspx.cs" Inherits="KenCommerceWeb.PublicWebsites.ForgotPassword" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link rel="stylesheet" href="<%#ResolveUrl("~")%>/DolnaWebsite/css/Custom.css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<%--Section Design Start--%>
<div class="container" style="margin-top: 155px;">
<div class="row">
<div class="col-md-12">
<div class="comment-box2">
<img alt="" src="<%#ResolveUrl("~")%>/DolnaWebsite/images/og.gif" />
<div class="comment-content">
<h2 class="h2s">Forgot Password
<span style="float: right;" class="st_sharethis" st_processed="yes">
<span style="text-decoration: none; color: rgb(0, 0, 0); display: inline-block; cursor: pointer; padding-left: 0px; padding-right: 0px; width: 16px;" class="stButton">
<span class="chicklets sharethis"> </span>
</span>
</span>
</h2>
<hr style="margin-top: 5px;margin-bottom: 5px; border: 0;border-top: 1px solid #000000;"/>
<p></p>
</div>
</div>
</div>
</div>
</div>
<%--Your Work--%>
<telerik:RadNotification RenderMode="Lightweight" ID="NotifiactionDisplaySection" runat="server" Position="TopCenter" TitleIcon="~/img/logo-footer.png"
AutoCloseDelay="3300" Width="450" Height="150" Title="Dolna" LoadContentOn="EveryShow">
</telerik:RadNotification>
<telerik:RadPageLayout runat="server" GridType="Fluid" CssClass="container" Width="70%">
<Rows>
<telerik:LayoutRow RowType="Container">
<Columns>
<telerik:LayoutColumn Span="4" SpanMd="4" SpanSm="12" SpanXs="12" Style="text-align:right;">
<span style="font-weight:500; font-size:medium;">Enter Your Registered EmailId :</span>
</telerik:LayoutColumn>
<telerik:LayoutColumn Span="7" SpanMd="7" SpanSm="12" SpanXs="12">
<telerik:RadTextBox ID="txtEmail" runat="server" Width="93%"></telerik:RadTextBox>
<asp:RequiredFieldValidator ID="reqfield" runat="server" ControlToValidate="txtEmail" ErrorMessage="*" Font-Bold="true" Font-Size="Large" ForeColor="Red" ValidationGroup="grpemail"></asp:RequiredFieldValidator>
</telerik:LayoutColumn>
</Columns>
</telerik:LayoutRow>
<telerik:LayoutRow Height="12px"></telerik:LayoutRow>
</Rows>
<Rows>
<telerik:LayoutRow RowType="Container">
<Columns>
<telerik:LayoutColumn Span="12" SpanMd="12" SpanSm="12" SpanXs="12" Style="text-align:center;">
<telerik:RadButton ID="RadSubmit" runat="server" Text="Submit" OnClick="RadSubmit_Click" ValidationGroup="grpemail"></telerik:RadButton>
<telerik:RadButton ID="RadCancel" runat="server" Text="Cancel" OnClick="RadCancel_Click" PostBackUrl="~/PublicWebsites/Login.aspx"></telerik:RadButton>
</telerik:LayoutColumn>
</Columns>
</telerik:LayoutRow>
</Rows>
</telerik:RadPageLayout>
<br />
<br />
<br />
<br />
<br />
<br />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link rel="stylesheet" href="<%#ResolveUrl("~")%>/DolnaWebsite/css/Custom.css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<%--Section Design Start--%>
<div class="container" style="margin-top: 155px;">
<div class="row">
<div class="col-md-12">
<div class="comment-box2">
<img alt="" src="<%#ResolveUrl("~")%>/DolnaWebsite/images/og.gif" />
<div class="comment-content">
<h2 class="h2s">Forgot Password
<span style="float: right;" class="st_sharethis" st_processed="yes">
<span style="text-decoration: none; color: rgb(0, 0, 0); display: inline-block; cursor: pointer; padding-left: 0px; padding-right: 0px; width: 16px;" class="stButton">
<span class="chicklets sharethis"> </span>
</span>
</span>
</h2>
<hr style="margin-top: 5px;margin-bottom: 5px; border: 0;border-top: 1px solid #000000;"/>
<p></p>
</div>
</div>
</div>
</div>
</div>
<%--Your Work--%>
<telerik:RadNotification RenderMode="Lightweight" ID="NotifiactionDisplaySection" runat="server" Position="TopCenter" TitleIcon="~/img/logo-footer.png"
AutoCloseDelay="3300" Width="450" Height="150" Title="Dolna" LoadContentOn="EveryShow">
</telerik:RadNotification>
<telerik:RadPageLayout runat="server" GridType="Fluid" CssClass="container" Width="70%">
<Rows>
<telerik:LayoutRow RowType="Container">
<Columns>
<telerik:LayoutColumn Span="4" SpanMd="4" SpanSm="12" SpanXs="12" Style="text-align:right;">
<span style="font-weight:500; font-size:medium;">Enter Your Registered EmailId :</span>
</telerik:LayoutColumn>
<telerik:LayoutColumn Span="7" SpanMd="7" SpanSm="12" SpanXs="12">
<telerik:RadTextBox ID="txtEmail" runat="server" Width="93%"></telerik:RadTextBox>
<asp:RequiredFieldValidator ID="reqfield" runat="server" ControlToValidate="txtEmail" ErrorMessage="*" Font-Bold="true" Font-Size="Large" ForeColor="Red" ValidationGroup="grpemail"></asp:RequiredFieldValidator>
</telerik:LayoutColumn>
</Columns>
</telerik:LayoutRow>
<telerik:LayoutRow Height="12px"></telerik:LayoutRow>
</Rows>
<Rows>
<telerik:LayoutRow RowType="Container">
<Columns>
<telerik:LayoutColumn Span="12" SpanMd="12" SpanSm="12" SpanXs="12" Style="text-align:center;">
<telerik:RadButton ID="RadSubmit" runat="server" Text="Submit" OnClick="RadSubmit_Click" ValidationGroup="grpemail"></telerik:RadButton>
<telerik:RadButton ID="RadCancel" runat="server" Text="Cancel" OnClick="RadCancel_Click" PostBackUrl="~/PublicWebsites/Login.aspx"></telerik:RadButton>
</telerik:LayoutColumn>
</Columns>
</telerik:LayoutRow>
</Rows>
</telerik:RadPageLayout>
<br />
<br />
<br />
<br />
<br />
<br />
</asp:Content>
================
using BusinessEntities;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net.Http;
using System.Net.Mail;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace KenCommerceWeb.PublicWebsites
{
public partial class ForgotPassword : System.Web.UI.Page
{
List<Master_Login_User> userList = null;
HttpClient client = new HttpClient();
HttpResponseMessage hrm = null;
protected void Page_Load(object sender, EventArgs e)
{
var appsurl = ConfigurationManager.AppSettings["APIPath"].ToString();
client.BaseAddress = new Uri(appsurl);
if (!Page.IsPostBack)
{
}
else
{
}
}
protected void RadSubmit_Click(object sender, EventArgs e)
{
HttpResponseMessage hrm = client.GetAsync("api/User").Result;
if (hrm.IsSuccessStatusCode)
{
userList = GetLogin_User().ToList().Where(a => a.Login_EmailId == txtEmail.Text && a.IsActive == true && a.IsDelete == false).ToList();
if (userList.Count > 0)
{
SendMail("Your Passeord is"+" "+userList.ToList()[0].Login_Password.ToString());
// Session["Loginuserid"] = userList.ToList()[0].Login_Password.ToString();
NotifiactionDisplaySection.Text = "Your Passwor is sent to your mail please check it. ";
NotifiactionDisplaySection.Show();
}
else
{
NotifiactionDisplaySection.Text = "User does not exist !";
NotifiactionDisplaySection.Show();
}
}
}
private List<Master_Login_User> GetLogin_User()
{
HttpResponseMessage Login_User = client.GetAsync("api/User").Result;
if (Login_User.IsSuccessStatusCode)
{
userList = Login_User.Content.ReadAsAsync<List<Master_Login_User>>().Result;
return userList.ToList();
}
else
{
return null;
}
}
#region MailIntegration
private void SendMail(string otpmsg)
{
string Froms = "satyabrata@kencloud.co.in";
string Tos = txtEmail.Text.Trim();
string UserName = string.Empty;
string url = string.Empty;
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress(Tos, txtEmail.Text.Trim()));
msg.From = new MailAddress(Froms, "Dolna");
msg.Subject = "Dolna Testing Mail Azure Web App Email using smtp.office365.com";
#region BodySetup
url = "http://kencommerce.azurewebsites.net/PublicWebsites/login.aspx";
//string body = "<html><body><img src='https://swasherpstorageaccount.blob.core.windows.net/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1image/2e35cb67-c088-468b-857d-59092e6c2b6e-.png'/></body></html>";
string body = "";
body += "Hi, " + txtEmail.Text.Trim();
body += "<br /><br />Thank you, for Dolna User.";
// body += "<br /><br />This is your One Time Password : " + TemporayUseOtp + " use this OTP to complete your registration ";
// body += "<br /><br />To Complete Your Registration and verify your email please use the following link";
// body += "<br/>Here Is Your Existing Password : <br/>" + Password + "";
// body += "<br /><a href=\"" + callbackUrl + "\" class='btn btn-default' >Click Here</a>";
body += "<br /><a href=\"" + url + "\" class='btn btn-default' >Activate your account</a>";
body += "<br /><b>OR</b>";
body += "<br />" + otpmsg + "</b>";
body += "<br /><br />If you cannot click on the link alternatively copy and paste in to your browser";
body += "<br /><br /> Best Wishes,";
body += "<br />SBackend Team";
body += "<html><body><img src='https://swasherpstorageaccount.blob.core.windows.net/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1/dolnastaging412a6577-8b12-4d7b-a8c9-7b911f36a4a1image/2e35cb67-c088-468b-857d-59092e6c2b6e-.png'/></body></html>";
body += "<br />---------------------------------------------------------------------------";
body += "<br /><b>This is a Auto generated message please donot reply back to this</b>";
#endregion
msg.Body = body; //"Test message using smtp.office365.com on Azure from a Web App";
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("satyabrata@kencloud.co.in", "chuma@1234");
client.Port = 587;
client.Host = "smtp.office365.com";
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
try
{
client.Send(msg);
// statusLabel.Text = "Message Sent Succesfully";
}
catch (Exception ex)
{
// statusLabel.Text = ex.ToString();
}
}
#endregion
protected void RadCancel_Click(object sender, EventArgs e)
{
Response.Redirect("~PublicWebsites/Login.aspx");
}
}
}
Comments
Post a Comment