Showing posts with label how to check if an email address already exists in the database in asp.net. Show all posts
Showing posts with label how to check if an email address already exists in the database in asp.net. Show all posts

Add prefix to the phone no column in SharePoint using JavaScript/JQuery

In this article we are able to see how to add prefix to the phone no in SharePoint list column using JavaScript.
enter only numbers in text box in SharePoint
Generate unique id in SharePoint using jQuery/JavaScript 
How to populate today’s date using JQuery in SharePoint
We are having a column with name Phone no, whenever we enter the number in that text box, once we click on save button, in the display form we can able to see the value like Call:987XXX3210.
We adding extent Call prefix before the Phoneno, we writing the code in PreSaveAction.

function PreSaveAction(){

try
{

var pno= document.querySelector('input[title^="Phoneno"]').value;
if(pno=="")
{

}
else
{
pno = pno.indexOf("Call:")==-1 ? 'Call:'+pno : pno;
$('input[title^="Phoneno"]').val(pno);
}
}
catch(e)
{
alert("error on save :"+e.message);

}
return true;
}


how to export data from gridview to Excel in asp.net using c#

how to export data from gridview to Excel in asp.net using c#

I will explain how to export data from gridview to Excel in asp.net using c#.

I created a database with table name EmployeeInfo as shown.

USE [chinnu]
GO

/****** Object: Table [dbo].[EmployeeInfo] Script Date: 10/29/2013 00:13:10 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[EmployeeInfo](
[EmpId] [nvarchar](50) NOT NULL,
[EmpName] [nvarchar](50) NOT NULL,
[EmpAddress] [nvarchar](50) NOT NULL,
[EmpDesignation] [nvarchar](50) NOT NULL
) ON [PRIMARY]

GO

In Default.aspx I am adding GridView and ImageButton as Shown.


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="file_conversion._Default" %>

<!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>
<body>
<form id="form1" runat="server">
<asp:GridView ID="gridview" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:BoundField DataField="EmpId" HeaderText="EmployeeId" InsertVisible="False"
/>
<asp:BoundField DataField="EmpName" HeaderText="EmployeeName" InsertVisible="False"
/>
<asp:BoundField DataField="EmpAddress" HeaderText="EmployeeAddress" />
<asp:BoundField DataField="EmpDesignation" HeaderText="EmployeeDesignation" />
</Columns>
</asp:GridView>
<asp:ImageButton ID="ImageButton1" runat="server" ToolTip ="Click To Export Excel Format" ImageUrl="Scripts/download (1).jpg" Width="32px" Height="32px"
OnClick="btnexcel_Click" />

</form>
</body>
</html>

Add iTextSharp DLL.
Now I am writing the logic in Default.aspx.cs to export gridview data in to Excel format as shown.

using System;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
using System.Data.SqlClient;


namespace file_conversion
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridData();
}
}
private void BindGridData()
{
try
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Connstring"].ConnectionString))
{
SqlCommand command = new SqlCommand("SELECT * from EmployeeInfo", con);
SqlDataAdapter da = new SqlDataAdapter(command);
DataTable dt = new DataTable();
da.Fill(dt);
gridview.DataSource = dt;
gridview.DataBind();
}
}
catch (Exception ex)
{
}

}
protected void btnexcel_Click(object sender, ImageClickEventArgs e)
{
string attachment = "attachment; filename=ExportData.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
gridview.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(gridview);
frm.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}

}

}

In web.config I am adding the ConnectionString

<connectionStrings>
<add name="Connstring" connectionString="Data Source=DotNetSharePoint;Database=Chinnu;User Id=sa;Password=password123;" providerName="System.Data.SqlClient" />
</connectionStrings>


Now Press F5.

OutPut:



how to generate random password in asp.net using c#

how to generate random password in asp.net using c#
In this article I will explain you how to generate random password in asp.net using c#.
Create one method and call that method in Insert mode or update mode. It generate random password.

Check the below code Example How to use.

 public static string CreateRandomPassword(int PasswordLength)
        {
            string _allowedChars = "0123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ";
            Random randNum = new Random();
            char[] chars = new char[PasswordLength];
            int allowedCharCount = _allowedChars.Length;
            for (int i = 0; i < PasswordLength; i++)
            {
                chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
            }
            return new string(chars);
        }




call this method in Insert mode or update mode,based upon your requirement.

If you give 8 meants it will show like this ZeXdjOdx

string pwd = CreateRandomPassword(8);

how to send username and password to email in asp.net

how to send username and password to email in asp.net
In this article I will explain how to send User id and password,when your are inserting the data first tie it will generate Password,it will sent mail to that Email id.

Add Name Space: using System.Net.Mail;

 public void sendingUidPwd(String Uid, String pwd)
        {
            try
            {
                MailMessage objeto_mail = new MailMessage();
                SmtpClient client = new SmtpClient();
                client.Port = 25;
                client.Host = "smtp.gmail.com";
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.UseDefaultCredentials = false;
                client.Credentials = new System.Net.NetworkCredential("yourmailid@gmail.com", "12345687");
                client.EnableSsl = true;
                objeto_mail.From = new MailAddress("yourmailid@gmail.com");
                objeto_mail.To.Add(new MailAddress(Uid));
                objeto_mail.Subject = "Your User ID and Password ";
                //objeto_mail.CC.Add(new MailAddress("phaniraavi@gmail.com"));
                objeto_mail.Body = "\n\nYour User ID and Password From RaaviChinnu.\n\n UserID : " + Uid + "\n\n Password : " + pwd;
                client.Send(objeto_mail);
            }
            catch (Exception)
            {
                
                
            }
        }



Call this method in Insert Method.

sendingUidPwd(txtEmailID.Text, pwd);

It will work :)

how to check if an email address already exists in the database in asp.net

In this article we can see how to find exiting email id from data base and it will display error message if it already exits
We created a method with name uniqueEmail.
Established a connection to the database.
Getting the data from the table  aspnet_Membership.
Using the ExecuteReader to read the values and checking the condition weather email id is already exists or not.


   public bool uniqueEmail()
        {
            
                string iemail;
                string constr = ABCDataAccessLayer.ABCConnctionString; // connection string
                SqlConnection con = new SqlConnection(constr);
                con.Open();
                string query = "select count(Email) as Email  from aspnet_Membership where Email= '" + txtEmailID.Text + "'";
                SqlCommand cmd = new SqlCommand(query, con);
                SqlDataReader dr;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    iemail = dr["Email"].ToString();
                    if (iemail != "0")
                    {
                        mailerror.Text = "Enter different email id";
                        return false;
                    }
                   
                }

                return true;
            
        }



Keep if condition,if you want to check email in insert mode or update mode
if (uniqueEmail())
{
Insert Code logic //
or
Update Code Logic
}

Output:

how to populate values in dropdownlist from database using asp.net

In this article we can able to see  how to Populate values in to drop down from Data Base using asp.net

 public void loadDdlRoles()
        {

            string constr = ConfigurationManager.ConnectionStrings["DConnectionString"].ToString(); // connection string
            SqlConnection con = new SqlConnection(constr);
            con.Open();

            SqlCommand com = new SqlCommand("select *from dbo.aspnet_Roles", con); // table name 
            SqlDataAdapter da = new SqlDataAdapter(com);
            DataSet ds = new DataSet();
            da.Fill(ds);  // fill dataset
            DdlRoles.DataValueField = ds.Tables[0].Columns["RoleName"].ToString();             // to retrive specific  textfield name 
            DdlRoles.DataSource = ds.Tables[0];      //assigning datasource to the dropdownlist
            DdlRoles.DataBind();  //binding dropdownlist


        }
Don't Forget to call that method in Page load

 protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                loadDdlRoles();
          }

        }
Keep always Smile:)

Labels

.Net Interview Questions add custom button in sharepoint using javascript Add custom column property into a PageLayout in SharePoint Add Page Title on their browser's title bar in SharePoint Customly add zip files in blogger Add-SPOSiteCollectionAppCatalog : Must have Manage Web Site permissions or be a tenant admin in order to add or remove sites from the site collection app catalog allow list Advance SmartObject An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL. Angular 2 Angular JS Angularjs Angularjs 1 anonymous users accessing lists and libraries App Permissions for SharePoint 2013 asp.net membership unique email Asp.net TreeView Control asp.net. Attendees in SharePoint Auto refresh list using Content Editor WebPart in SharePoint 2013. Auto Refresh SharePoint list using JavaScript Block and unblock of attachment types in SharePoint Blogger C# Callouts in SharePoint 2013 Cascading Dropdown list in SharePoint change onenote to another location. change SuiteBarLeft in SharePoint 2013 check if userid exists in database c# click node text to expand/collapse in Treeview client object model Close webpart CQWP crate chart using BI site in PPS Create a modern team site collection in SharePoint online Create BI chart in PPS SharePoint 2013 create filter in dashboard designer. create kpi's in dashboard designer create kpi's in SharePoint 2013 dashboard designer Create List Create List In SharePoint Create List using Power Shell Script Create Lookup Field in List using Power Shell Script Create lookup field in List create SharePoint List custom view. create SharePoint List views in List Schema create site collection in site collection in SharePoint using powershell created Date Time calculated field in SharePoint Cross site Collection in SharePoint 2013 Crud Operation in Asp.net Using Stored Procedure Custom MasterPage Approval in SharePoint custom view for survey list Customly add SharePoint List view in Page. delete items in sharepoint using powershell Difference between Angular 1.x & Angular 2 difference between Office 365 and Windows Azure difference between Windows Azure and Office 365 in sharepoint? DifferenceBetween discussion board Display Data in Grid View display radio buttons and choice fields horizontally in SharePoint 2013 Document library DotNet Drag and drop documents in document library in SharePoint dynamically populating values from one list to another list using jquery in sharepoint edit and delete buttons in datagridview Edit Links email notification using Nintex enable anonymous access in SharePoint 2013 enable app catalog sharepoint online site collection powershell Enable appcatalog site collection level using PowerShell based on Input file Enable versions for list and library except the hidden lists using PowerShell Script Error occurred in deployment step 'Recycle IIS Application Pool': Cannot resolve model for the project package Errors&Solutions Export document library in sharepoint using powershell Export particular Group in Term Store Management in SharePoint 2013 Export to Excel first release Flow Flow features free disk space on servers using powershell Friendly URLs and Managed Navigation in SharePoint 2013 get a list of site collection with template in web application using PowerShell Script in SharePoint Get attachments in SharePoint custom list using c# get current list item id sharepoint programmatically Get current url using jquery Get data from SharePoint list using Rest api & Angular JS Get Random Get Random SharePoint items using PowerShell Get Random values from SharePoint list using PowerShell Get url of the last value using jquery Get-SPOSite : The managed path sites/yoursitename is not a managed path in this tenant. Getting Email From User Hide “Edit Links” in left navigation SharePoint 2013 hide button in sharepoint based on permissions Hide column in SharePoint List view hide fields using client side object model Hide list in Quick Launch in SharePoint using PowerShell How to add Custom Tiles to SharePoint site Page. How to add extension files in Search Navigation in SharePoint 2013 How to Add Multiple users Using SharePoint People Picker How to add SharePoint list view in Page using C# How to Approve MasterPage using PowerShell in SharePoint How to bind Multiple users Using SharePoint People Picker how to change indicators on kpi performance how to check if an email address already exists in the database in asp.net how to configure workflow manager platform for SharePoint 2013 how to create calculated value using powershell how to create certificate in SharePoint How to create flow. how to create gantt chart webpart in sharepoint how to create KPI indicators in Dashboard designer How to create moden communication site in SharePoint online How to create Multi selected filter in Dashboard How to create nintex workflow in sharepoint how to create rdlc reports in asp.net How to Display Data Grid View in ASP.net How to enable anonymous access in SharePoint How to find data in datagridview in c# How to get image names from the folder using C# how to get particular list content type id in SharePoint 2013 How to get QueryString value in SharePoint WebPart Programatically how to get the current item id for newly created item using REST API and JQuery how to hide list in sharepoint how to know who created list in sharepoint How to make a Site Collection Read-Only in SharePoint 2010 How to overlay Office 365 shared calendar on SharePoint Site how to pass jquery value to asp.net textbox control How to pass pagename as a browser's title bar in the page how to remove unused Application Pool in SharePoint how to remove zone using powershell script How to send mail to particular group of people using PowerShell how to update modified by and created by using powershell how to uplaod RAR files in blogger import csv data into sharepoint import data using powershell Import group to term store management using SharePoint 2013. InfoPath InfoPath Cascading Dropdown list Insert update delete in datagridview in C# winforms Integration from SharePoint to k2. K2 Smart Forms for SharePoint JavaScript Injection jquery JSON K2 blackpearl K2 Designer K2 Designer Workflow. K2 smartform cascading dropdown list k2 Workflow K2 workflow to send a mail with PDF left navigation Local Term Set in managed meta data Managed meta data navigation in SharePoint 2013 Managed metadata service in SharePoint 2013. Managed Navigation in SharePoint 2013. Managed Promoted Sites. meta data navigation Microsoft Flow New Features New-SPConfigurationDatabase The user does not exist or is not unique NintexWorkFlow Office 365 OneDrive OneNote overwrite existing document in sharepoint using javascript PDF Converter PDF Method in K2 Performance Point Service in SharePoint 2013 PerformancePoint Services Configurtion PerformancePoint Services Configurtion for SharePoint 2013 PerformancePoint Services in SharePoint Server 2013 Popularity trends in SharePoint 2013 Pages populate dropdown list dynamicallyusing jquery Power Power Automate Power Shell Power shell script to get SharePoint site size. PowerApps powershell read xml PowerShell Script PowerShell script to get list of users from SharePoint groups PowerShell Scripts in SharePoint 2013 Powershell to set the masterpage in SharePoint Promoted Links Promoted Sites psconfig.exe quick launch Rdlc reports Readonly Column in SharePoint Editview Realtime DotNet Interview Questions Recent Dotnet interview questions Recent SharePoint interview questions recover deleted OneNote page. OneNote content is missing Regional Settings in SharePoint 2013 Replace New Item text in SharePoint Rest API Schedule PowerShell Script Search in SharePoint 2013 Search navigation in SharePoint 2013 Secure store service SecureStore Services SecureStore Services configuration for SharePoint 2013 self-signed certificate on IIS Server Send email to members of SharePoint Group using PowerShell sharepint2010 sharepoin2010 SharePoint 2013 SharePoint 2010 SharePoint 2013 SharePoint 2013 Dashboard Designer SharePoint 2013 features SharePoint 2013 Interview Questions SharePoint 2013. SharePoint 2013.disable views from user to create SharePoint 2013.Power shell SharePoint 2013.SharePoint 2010 SharePoint 2016 SharePoint Administration SharePoint Alerts and Reminders SharePoint App Configuration SharePoint Apps SharePoint Bulk upload SharePoint Calculated field SharePoint Calendar View sharepoint interview questions SharePoint online interview questions SharePoint online training SharePoint Onprem vs Online SharePoint RealTime Online Training SharePoint2010 SharePoint2013 SharePoint2016 SharePointInterview SharePointOnline SharePointOnline;Restore deleted site;SharePoint 2013 show data in datagridview in C# Simple Insert update Delete Retrieve Clear in asp.net. Site Collection Operations in SharePoint 2013 Site Collection Read-Only in SharePoint 2013 site contents Sorting & Filtering SPO SPSite Site Collection Operation parameters in SharePoint 2013 Step by step to create rdlc report in .Net Store names in text files in C# Sub site Subsite Term store management. The server was unable to save the form at this time. please try again UI New look update created by using client side object model update field values in SharePoint using powershell update items in SharePoint list using client object model update modified by field using client side object model upload zip files in blog use IsNullOrEmpty in PowerShell VirtoSoftware VirtoSofware vitrosoftware WebParts what is Document Set in SharePoint 2010 What is Filter in SharePoint Dashboard what is Limited-access user permission lock down mode feature What is Modern Team site What is Target Audience in SharePoint Who Created Site Using PowerShell Workflow in SharePoint 2013 Workflow management platform in SharePoint 2013 Workflow manager for SharePoint 2013 XSL-Template.