Hello Guys
I want to Concatenate Javascript function with anchor tag that is coded in Code behind Cs file.
The purpose is to show a messege with the url to navigate the client to his login page if he has been already registered inside a popup window. How can i achieve it. Please tell?
HTML
<%@ Page Title="Registration" Language="C#" MasterPageFile="~/include/master/customer.master"
AutoEventWireup="true" CodeFile="registeration.aspx.cs" Inherits="registeration" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script type="text/javascript" src="/include/js/ModalPopupWindow.js">
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div class="container mg">
<div class="wrapper_adminpannel">
<div class="container_content c_login_bg">
<div class="customer_login c_txt">
<div class="c_login_area c_login_hed c_login_center">
Register Customer
</div>
<div style="padding-left:10px; text-align:justify">
<asp:Label ID="lblTop" runat="server" Text="Label" ForeColor="Red" Font-Size="16px"
Visible="false"></asp:Label></div>
<div class="login_area1 h2" style="padding-top: 36px">
<asp:Label ID="lblFirstName" runat="server" Font-Size="X-Large"><span style ="color:Red">*</span>First Name</asp:Label></div>
<div class="c_login_area c_login_center">
<asp:TextBox ID="txtFirstName" CssClass="login_field" runat="server" autofocus="autofocus"></asp:TextBox>
<div>
<asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ErrorMessage="Fill Details"
ControlToValidate="txtFirstName" ForeColor="Red" Font-Size="17px"></asp:RequiredFieldValidator></div>
</div>
<div class="login_area1 h2" style="padding-top: 28px">
<asp:Label ID="lblMiddleName" runat="server" Text="Middle Name" Font-Size="X-Large"></asp:Label></div>
<div class="c_login_area c_login_center">
<asp:TextBox ID="txtMiddleName" CssClass="login_field" runat="server" Font-Size="X-Large"></asp:TextBox>
</div>
<div class="login_area1 h2" style="padding-top: 51px">
<asp:Label ID="lblLastName" runat="server" Font-Size="X-Large"><span style ="color:Red">*</span>Last Name</asp:Label></div>
<div class="c_login_area c_login_center">
<asp:TextBox ID="txtLastName" CssClass="login_field" runat="server"></asp:TextBox>
<div>
<asp:RequiredFieldValidator ID="rfvLastName" runat="server" ForeColor="Red" Font-Size="17px"
ErrorMessage="Fill Details" ControlToValidate="txtLastName"></asp:RequiredFieldValidator>
</div>
</div>
<div class="login_area1 h2" style="padding-top: 29px">
<asp:Label ID="lblEmail" runat="server" Font-Size="X-Large"><span style ="color:Red">*</span>Email</asp:Label></div>
<div class="c_login_area c_login_center">
<asp:TextBox ID="txtEmail" CssClass="login_field" runat="server"></asp:TextBox>
<div>
<span>
<asp:Label ID="lblMessage" runat="server" Text="Label" ForeColor="Red" Font-Size="15px"
Visible="false"></asp:Label></span>
<div>
<asp:RegularExpressionValidator ID="revEmail" runat="server" ErrorMessage="Invalid Email"
Font-Size="17px" SetFocusOnError="true" ForeColor="Red" ControlToValidate="txtEmail"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</div>
</div>
</div>
<div class="login_area1 h2" style="padding-top: 27px">
<asp:Label ID="lblPassword" runat="server" Font-Size="X-Large"><span style ="color:Red">*</span>Password<span class="comment_style">(should not contain spaces)</span></asp:Label></div>
<div class="c_login_area c_login_center">
<asp:TextBox ID="txtPassword" CssClass="login_field" runat="server" TextMode="Password"></asp:TextBox>
<div>
<asp:RequiredFieldValidator ID="rfvPassword" runat="server" ForeColor="Red" Font-Size="17px"
ErrorMessage="Fill Details" ControlToValidate="txtPassword"></asp:RequiredFieldValidator>
</div>
</div>
<div class="login_area1 h2" style="padding-top: 28px">
<asp:Label ID="lblConfirmPassword" runat="server" Font-Size="X-Large"><span style ="color:Red">*</span>Confirm Password</asp:Label></div>
<div class="c_login_area c_login_center">
<asp:TextBox ID="txtConfirmPassword" CssClass="login_field" runat="server" TextMode="Password"></asp:TextBox>
<div>
<asp:RequiredFieldValidator ID="rfvConfirmPassword" runat="server" ErrorMessage="Fill Details"
ControlToValidate="txtConfirmPassword" ForeColor="Red" Font-Size="17px"></asp:RequiredFieldValidator></div>
<span>
<asp:CompareValidator ID="cvConfirmPassword" runat="server" ErrorMessage="Password does not Match"
ControlToValidate="txtConfirmPassword" ForeColor="Red" Font-Size="15px" ControlToCompare="txtPassword"></asp:CompareValidator></span>
</div>
<div class="login_area1 h2">
<asp:Label ID="lblMobile" runat="server" Text=" Mobile" Font-Size="X-Large"></asp:Label></div>
<div class="c_login_area c_login_center">
<asp:TextBox ID="txtMobile" CssClass="login_field" runat="server"></asp:TextBox>
</div>
<div class="login_area1 h2" style="padding-top: 40px">
<asp:Label ID="lblPhone" runat="server" Text="Phone" Font-Size="X-Large"></asp:Label></div>
<div class="c_login_area c_login_center">
<asp:TextBox ID="txtPhone" CssClass="login_field" runat="server"></asp:TextBox>
</div>
<div class="login_area1 h2" style="padding-top: 48px">
<asp:Label ID="lblComments" runat="server" Font-Size="X-Large">Comments<span class="comment_style">(Not exceeding 450 characters)</span></asp:Label></div>
<div class="c_login_area c_login_center">
<asp:TextBox ID="txtComments" CssClass="comment_field" runat="server"
TextMode="MultiLine"></asp:TextBox><span><asp:RegularExpressionValidator ID="revComments"
runat="server" ErrorMessage="You cannot specify more than 450 characters"
Font-Size="17px" ForeColor="Red" ValidationExpression="^[\s\S]{0,450}$"
ControlToValidate="txtComments"></asp:RegularExpressionValidator></span>
</div>
<div style="padding-left:20px">
<asp:Label ID="lblRequiredField" runat="server" Font-Size="17px"><span style ="color:Red">*</span>Required Field</asp:Label>
</div>
<div class="c_login_area" style="padding-top:50px">
<asp:Button ID="btnRegister" CssClass="login_btn" runat="server" Text="Register"
OnClick="btnRegister_Click"/>
</div>
<asp:CustomValidator ID="CsvEmail" runat="server" Font-Size="17px" ForeColor="Red"
OnServerValidate="btnRegister_Click" ControlToValidate="txtEmail" Visible="false"></asp:CustomValidator>
<div>
<asp:HiddenField ID="hdField" runat="server" />
</div>
</div>
</div>
</div>
</div>
<script>
var popup = CreateModalPopUpObject();
function Confirmation() {
popup.ShowMessage("You are Successfully Registered", 400, 400, "Messege");
}
function VerificationPending() {
popup.ShowMessage("This email address is already registered but your account verification is pending. Please check your email address for verification code and enter your code", 250, 400, "Verification Messege")
}
</script>
</asp:Content>
CS File
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
using CloudPOS;
public partial class registeration : System.Web.UI.Page
{
private string m_sPageUrl = string.Empty;
private string m_sEmail = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.clearFunction();
}
}
protected void btnRegister_Click(object sender, EventArgs e)
{
CommonUsercl oCommonUsercl = new CommonUsercl();
DataTable oDatatable = oCommonUsercl.GetUserTypeDetails(txtEmail.Text, CommonUsercl.eUserType.Client_Customer);
bool bVerified = oCommonUsercl.GetVerifiedUser(txtEmail.Text, CommonUsercl.eUserType.Client_Customer);
int iUserId = oCommonUsercl.GetUserId(txtEmail.Text, CommonUsercl.eUserType.Client_Customer);
if (oDatatable.Rows.Count > 0 && bVerified == true)
{
ScriptManager.RegisterStartupScript(this, GetType(), "none", "<script>Confirmation();</script>", false);
}
else if (oDatatable.Rows.Count > 0 && bVerified == false)
{
ScriptManager.RegisterStartupScript(this, GetType(), "none", "<script>VerificationPending();</script>", false);
}
else if (string.IsNullOrEmpty(txtEmail.Text) == true)
{
CsvEmail.ErrorMessage = "Fill Details";
lblTop.Visible = false;
lblMessage.Text = CsvEmail.ErrorMessage;
lblMessage.Visible = true;
}
else
{
int iVerificationCode = this.GenerateRandomVerificationCode();
hdField.Value = Stringcl.GetValue(oCommonUsercl.AddUserDetails(txtEmail.Text.Trim(), txtPassword.Text.Trim(), CommonUsercl.GetUserTypeId(CommonUsercl.eUserType.Client_Customer), txtFirstName.Text.Trim(), txtMiddleName.Text.Trim(), txtLastName.Text.Trim(), txtMobile.Text.Trim(), txtPhone.Text.Trim(), txtComments.Text.Trim(), Stringcl.GetValue(iVerificationCode), false, true));
string sName = txtFirstName.Text;
string sEmail = "<html><head><title>CloudPOS - Verify Your Account</title></head><body><p>Dear " + sName + ", </p>";
sEmail += " <p> We have received your request to set up a new account. To ensure account security please click on the link below to complete verification :</p>";
sEmail += "<p><b>Verification Url</b> : <a href='" + Applicationcl.GetWebsiteUrl() + "/verify.aspx?i=" + hdField.Value + "'>"
+ Applicationcl.GetWebsiteUrl() + "/verify.aspx?i=" + hdField.Value + "</a><br/><b>Authentication Code</b> : " + iVerificationCode
+ "#EMAIL_SIGNATURE#</body></html>";
Emailcl oEmailcl = new Emailcl();
oEmailcl.SendEmail(Emailcl.enmModule.Regular, txtEmail.Text, "", "CloudPOS: Verfication Mail", sEmail, true);
ScriptManager.RegisterStartupScript(this, GetType(), "none", "<script>Confirmation();</script>", false);
}
}
public int GenerateRandomVerificationCode()
{
Random oRandom = new Random();
int iVerificationCode = oRandom.Next(10000, 99999);
return iVerificationCode;
}
private void clearFunction()
{
txtFirstName.Text = string.Empty;
txtMiddleName.Text = string.Empty;
txtLastName.Text = string.Empty;
txtPhone.Text = string.Empty;
txtMobile.Text = string.Empty;
txtComments.Text = string.Empty;
lblTop.Text = string.Empty;
txtEmail.Text = string.Empty;
}
}