Saturday, 19 October 2013

How to get Gmail authentication in our ASP.NET web sites



Today am going to explain how to authenticate a person to enter our own web site using his Gmail credentials.

Purpose

Generally when a person registers himself in a website, a return mail is sent to him either confirming his registration or sending a password. If the user provides any invalid mail id also the application tries to send a mail. Even CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) code is also of no use when the user provides an invalid mail address. As majority of applications use SMTP (Simple Mail Transfer Protocol) no error message is displayed when Gmail returns a mailer demon message. This increases the processing time of the application and also wastes memory. Even sometimes we don’t want the user’s entire details to store in our database. In such conditions we’ll use Gmail authentication.
The Gmail authentication helps us to confirm that the registering person is a valid user. When we ask the user to register him using his Gmail credentials he need not worry about his password identification. When a person is registered using his Gmail credentials, the Gmail provides only the first and last name, date of birth, country, email id of the registered person. It won’t display the password, phone number, contacts of the registered person etc. even to the developer. So this is completely secured code .

Friday, 18 October 2013

Binding data to drop down list in C# .NET


In this article I will explain how to bind data to Dropdown list

This control supports data binding.

Below is method

First we need to declare a drop down list. We have an asp tag to add a drop down list.

<asp:DropDownList>

We will give an ID to every field. We are declaring a drop down list called “ddlClient”. Here we can mention the dimensions of the drop down list.

Width=”220px”

How to Change Gridview background Row colour dynamically in asp.net & c#


In this article I will explain how to Change Gridview background Row colour dynamically in ASP.NET & C#.NET

Write the below code in GridViewRow data bound event.

Below code is very useful for conditions based.

 protected void gvNew_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        DataRowView drv = (DataRowView)e.Row.DataItem;
                 if (e.Row.RowType == DataControlRowType.DataRow)
        {

            Label lblCategoryMain = (Label)e.Row.FindControl("lblCostCategory");
            if (lblCategoryMain != null)
            {
                if (lblCategoryMain.Text == "1")
                {
                                        e.Row.Cells[1].BackColor =   System.Drawing.Color.LightGray;
                    e.Row.Cells[1].ForeColor = System.Drawing.Color.Black;
                }
                if (lblCategoryMain.Text == "2")
                {
                    e.Row.Cells[1].BackColor = System.Drawing.Color.Gray;
                    e.Row.Cells[1].ForeColor = System.Drawing.Color.Black;
                }
                if (lblCategoryMain.Text.Trim() == "3")
                {
                    e.Row.Cells[1].BackColor = System.Drawing.Color.LightGreen;
                    e.Row.Cells[1].ForeColor = System.Drawing.Color.Black;
                }
                if (lblCategoryMain.Text == "4")
                {
                    e.Row.Cells[1].BackColor = System.Drawing.Color.LightSeaGreen;
                    e.Row.Cells[1].ForeColor = System.Drawing.Color.Black;
                }
            }

        }

What is the difference between DataReader, Dataset and DataAdapter ?


In this article I will explain what is the difference between DataReader, Dataset and  DataAdapter ?

DataReader

ADO.NET DataReader to retrieve a read-only, forward-only stream of data from a database. DataReader is used to iterate through resultset that came from server and it will read one record at a time because of that memory consumption will be less and it will fetch the data very fast when compared with dataset.

C# Code 
// This method is used to bind gridview from database
protected void BindGridview()
{
using (SqlConnection con = new SqlConnection(Enter your connection string))
{
con.Open();
SqlCommand cmd = new SqlCommand("Select UserName,LastName,Location FROM UserInformation", con);
SqlDataReader dr = cmd.ExecuteReader();
gvUserInfo.DataSource = dr;
gvUserInfo.DataBind();
con.Close();
}
}

How to join two table using LINQ (Language Integrated Query)


In this articel i will explain what is LINQ? what are the advantages and disadvantages with examples 

What Is LINQ

Language-Integrated Query (LINQ) is a set of features introduced in Visual Studio 2008 that extends powerful query capabilities to the language syntax of C# and Visual Basic. LINQ introduces standard, easily-learned patterns for querying and updating data, and the technology can be extended to support potentially any kind of data store. Visual Studio includes LINQ provider assemblies that enable the use of LINQ with .NET Framework collections, SQL Server databases, ADO.NET Datasets, and XML documents.

Thursday, 17 October 2013

how to show alert message from server side using asp.net in C#


In this article I will explain how to show alert message from server side using asp.net in C#.

To display JavaScript alert message from server side we need to use 

Syntax:

ScriptManager.RegisterStartupScript() method.

ScriptManager.RegisterStartupScript(Control control, Type type,string key, string script,
bool addScriptTags)

Wednesday, 9 October 2013

How to restrict the entry of alphabets in a textbox using javascript




In this article I will explain how to restrict the entry of alphabets in a textbox.


Why do we need to restrict

In our application we may have a field like a phone numbers field or a number entry field. Here we need to enter only numbers. There are few validation methods which generate an alert message when we click the submit button or when we move the cursor from that textbox. But we can write a keypress event which restricts the entry of alphabets i.e. when you press the keys, or buttons other than 0 to 9; they are not entered into the textbox. This reduces the validation coding.

Now let’s have a look at the code

Saturday, 5 October 2013

How to clear FileUpload Control data using JavaScript in ASP.NET


In this article I will explain How to clear FileUpload Control data using JavaScript in ASP.NET

To clear file upload control in JavaScript we need to write the following code your page

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<title>validate fileupload control using Jquery in ASP.NET</title>
<script language="javascript" type="text/javascript">
function ClearFileUploadControl() {
var uplctrl = document.getElementById("fileupload1");
uplctrl.select();
clrctrl = uplctrl.createTextRange();
clrctrl.execCommand('delete');
uplctrl.focus();
}
</script>
</head>

How to get ASP.NET Label and TextBox values in JavaScript


 In this article I will explain How to get ASP.NET Label and TextBox values in JavaScript

Get Asp.net Textbox And Label Value in JavaScript

To get ASP.NET textbox or label value in JavaScript we need to write a code like as shown below

Get label value
var Name = document.getElementById("<%=lblName.ClientID %>").innerHTML

Get label value

var LastName = document.getElementById("<%=txtLastName.ClientID %>").value;

Friday, 4 October 2013

How to write code for Jquery modal popup in asp.net


In this article I will explain How to apply CSS to model popup? And How to design Model popup window?
Below is the design for model popup code. Copy and paste it into your ASPX page and check.
<html>
<head>
<title>jQuery Popup Dialog - Click</title>
<style type="text/css">
#overlay {
positionfixed;
top0;
left0;
width100%;
height100%;
background-color#000;
filter:alpha(opacity=70);
-moz-opacity:0.7;
-khtml-opacity0.7;
opacity0.7;
z-index100;
displaynone;
}
.content a{
text-decorationnone;
}
.popup{
width100%;
margin0 auto;
displaynone;
positionfixed;
z-index101;
}