Sunday, September 29, 2013

How to use SiteMapPath Navigation Control in Asp.net

Introduction: In this article I have explain How to use SiteMapPath Navigation Control in Asp.net



Description:

Right click on Project/Website name > Add New Item > Select Site Map as mention in attached snapshot: 


You see the structure as show below:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="" title=""  description="">
        <siteMapNode url="" title=""  description="" />
        <siteMapNode url="" title=""  description="" />
    </siteMapNode>
</siteMap>

Enter the .aspx page name in URL, Title and Description as shown in below example:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="Default.aspx" title="Home"  description="Home Page">
        <siteMapNode url="About_Us.aspx" title="About Us"  description="Aount Us Page" />
      <!--For Sub menu (Here Photo Gallery is Sub menu of Achievement Menu)-->
      <siteMapNode url="Achievements.aspx" title="Achievement" description="Achievements Page">
        <siteMapNode url="Photo_Gallery.aspx" title="Photo Gallery" description="Photo Gallery Page"/>
      </siteMapNode>
        <siteMapNode url="Contact_Us.aspx" title="Contact Us"  description="Contact Us Page" />
    </siteMapNode>
</siteMap>

Add a new webform to project. Drag and drop the control SiteMapPath from Toolbox> Navigation as show in attached snapshot:


After that you can change the formating of SiteMapPath via click on Auto Foramt, choose your style or can add the CssClass in Properties
  <asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana"
            Font-Size="0.8em" PathSeparator=" : ">
        <CurrentNodeStyle ForeColor="#333333" />
        <NodeStyle Font-Bold="True" ForeColor="#7C6F57" />
        <PathSeparatorStyle Font-Bold="True" ForeColor="#5D7B9D" />
        <RootNodeStyle Font-Bold="True" ForeColor="#5D7B9D" />
        </asp:SiteMapPath>

Run the project and check the result.

Is it helpful?

If yes post your comment to admire my work. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.

Wednesday, September 25, 2013

Validate DropDownlist using Jquery in asp.net

Introduction: In this article I have explain how we can validate the DropDownlist using Jquery in asp.net.
Validate DropDownlist

Description:
Add a new webform to project. Drag and drop the DropDownlist and button controls from Toolbox. Desgin the .aspx page as shown below:
<table align="center">
    <tr><td>Known Language:</td><td><asp:DropDownList ID="ddllanguage" runat="server">
    <asp:ListItem Text="Select" Value="0" />
<asp:ListItem Text="English" Value="1" />
<asp:ListItem Text="Hindi" Value="2" />
<asp:ListItem Text="Punjabi" Value="3" />
<asp:ListItem Text="German" Value="4" />
    </asp:DropDownList></td></tr>
                        <tr>&nbsp;</tr>
                    <tr><td>&nbsp;</td><td>
                        <asp:Button ID="btnsubmit" runat="server" Text="Submit"/></td></tr>
    </table>

After that put the given Jquery in .aspx page between Head Tag:
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $('#btnsubmit').click(function () {
            if ($("#ddllanguage").val() > 0) {
                return true;
            }
            else {
                alert('Please select Known Language')
                return false;
            }
        })
    });
</script>

Run the project and check out the result.

Is it helpful?

If yes post your comment to admire my work. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.

Friday, September 20, 2013

Store Password in Encrypted format to Database in asp.net

Introduction: In this article I have explain how we can insert the password in encrypted format to database.
 encrypted password

Description:

I created a Table USER_REGISTRATION:
ID
int
USERNAME
varchar(50)
PASSWORD
varchar(50)
FIRST_NAME
varchar(50)
LAST_NAME
varchar(50)
SEX
varchar(50)
PHONE
int
EMAIL_ID
varchar(50)

Here ID is autoincrement and primary key.
Add a webform to project. Drag and drop the controls Textbox, button from Toolbox and design the page show below:
<div class="form">
    <table>
    <tr><td>Username:-</td><td>
        <asp:TextBox ID="txtusername" runat="server"></asp:TextBox>
      

Tuesday, September 10, 2013

Auto refresh data in Gridview without loading whole page in asp.net

Introduction: In this post I will explain how we can Auto refresh data in Gridview without loading whole page in asp.net using ajax.
Auto refresh data in Gridview

Description:

Add a webform to project. Drag and drop the Gridview, Update Panel control from Toolbox and desgin the .aspx as shown below:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
    <script type="text/javascript" src="js/gridviewScroll.min.js"></script>
    <script type="text/javascript" src="js/scrollsaver.min.js"></script>
    <link href="css/GridviewScroll.css" rel="stylesheet" />
    <style type="text/css">
       BODY,TD
              {
                  font-family: ·L³n¥¿¶Ã‚Åé, Tahoma, Arial, Verdana;
                  font-weight: normal;
                  font-size: 14px;
                  color: #000;
              }
    </style>

Monday, September 9, 2013

Add Meta Tag Code behind in asp.net

Introduction: In this article I will expalin how we can Add Meta Tag Code behind in asp.net.
Description:

We need to add Meta tag code behind/Dynamically in application. Suppose in application we create Content pages from Master page but we want to add different page title, Title, Description and keyword for each page.
Add a new webform or create content page from master page. On .aspx.cs page write the mention code:
protected void Page_Load(object sender, EventArgs e)
    {
        //add meta tag dynamically
        Page.Title = "Enter Page Title";

        //add meta title
        HtmlMeta metatitle = new HtmlMeta();
        metatitle.Name = "Title";
        metatitle.Content = "Enter Meta Title";
        Page.Header.Controls.Add(metatitle);

        //add meta description
        HtmlMeta metadesc = new HtmlMeta();
        metadesc.Name = "description";
        metadesc.Content = "Enter Description";
        Page.Header.Controls.Add(metadesc);

        //add meta keywords
        HtmlMeta metakeyword = new HtmlMeta();
        metakeyword.Name = "keywords";
        metakeyword.Content = "Enter Keywords";
        Page.Header.Controls.Add(metakeyword);
    }

In VB (.aspx.vb)

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'add meta tag dynamically
        Page.Title = "Enter Page Title"

        'add meta title
        Dim metatitle As New HtmlMeta()
        metatitle.Name = "Title"
        metatitle.Content = "Enter Meta Title"
        Page.Header.Controls.Add(metatitle)

        'add meta description
        Dim metadesc As New HtmlMeta()
        metadesc.Name = "description"
        metadesc.Content = "Enter Description"
        Page.Header.Controls.Add(metadesc)

        'add meta keywords
        Dim metakeyword As New HtmlMeta()
        metakeyword.Name = "keywords"
        metakeyword.Content = "Enter Keywords"
        Page.Header.Controls.Add(metakeyword)

    End Sub
Run the project. To check Meta Tag right click on page>>View Page Source. See in Head tag Meta Tags are added to page.

Is it helpful?

If yes post your comment to admire my work. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.

Friday, September 6, 2013

Encrypt and Decrypt Query String in asp.net

Introduction: In this article I have explain how we can Encrypt and Decrypt Query String in asp.net.

Description:

Add a weform to project. Drag and drop the controls from Toolbox and desgin the .aspx page as given below:
<table align="center"><tr><td>Employee Name:</td><td><asp:TextBox ID="txtname" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="rfvname" runat="server"
            ControlToValidate="txtname" ErrorMessage="Enter Employee Name"
            ForeColor="#FF3300"></asp:RequiredFieldValidator>
        </td></tr>
    <tr><td>&nbsp;</td><td> <asp:Button ID="btnSubmit" runat="server" Text="Submit"
            onclick="btnSubmit_Click" /></td></tr>
    </table>    

On Button click write the below given code (.aspx.cs)

Thursday, September 5, 2013

Create multiple Language website in Asp.net

Introduction: In this post I will try to explain how we can create Multilanguage website in asp.net.
multiple Language

Description:

Take a new Website/Project. Now add a Resource File to website/project (Right click on website >> Add New item>> Resource File)  as mention in attached snapshot:

multiple Language

Monday, September 2, 2013

Edit, Update and Delete in Gridview using three tier architecture in Asp.net using SqlHelper

Introduction: In this article I have explained how we can Bind, Edit, Update and Delete in Gridview using three tier architecture in Asp.net.
three tier architecture

Description:
I have  a Table USER_REGISTRATION:
ID
int
USERNAME
varchar(50)
PASSWORD
varchar(50)
FIRST_NAME
varchar(50)
LAST_NAME
varchar(50)
SEX
varchar(50)
EMAIL_ID
varchar(50)

Here ID is autoincrement and primary key.

Create a Store Procedure to Delete the Records:

CREATE PROCEDURE [dbo].[DELETE_USER]
(
@ID INT
)
AS
BEGIN
      SET NOCOUNT ON;
   DELETE FROM dbo.USER_REGISTRATION WHERE ID = @ID
END

Create a Store Procedure to Update the Records/Data:

CREATE PROCEDURE [dbo].[UPDATE_USER]
(
@ID INT,
@USERNAME varchar(50),
@FIRST_NAME varchar(50),
@LAST_NAME varchar(50),
@EMAIL_ID varchar(50),
@SEX VARCHAR(50)
)
AS
BEGIN
      SET NOCOUNT ON;

  UPDATE dbo.USER_REGISTRATION SET USERNAME= @USERNAME, FIRST_NAME=@FIRST_NAME, LAST_NAME=@LAST_NAME, EMAIL_ID=@EMAIL_ID, SEX=@SEX
   WHERE ID=@ID
END

Add a new Class  to clsuserRegistartion.cs to Bussiness Layer (DataEntities) of Project:

public class clsuserRegistartion
    {
       public int ID {get;set;}
       public string USERNAME { get; set; }
       public string PASSWORD { get; set; }
       public string FIRST_NAME { get; set; }
       public string LAST_NAME { get; set; }
       public string SEX { get; set; }
       public string EMAIL_ID { get; set; }
    }

Validate Checkboxlist using Jquery in asp.net

Introduction: In this article I have explain how we can validate the CheckBoxlist using Jquery in asp.net.
Validate Checkboxlist

Description:
Add a webform to project. Drag and drop the CheckBoxlist and button controls from Toolbox. Desgin the .aspx as shown below:
<table align="center"><tr><td>Known Language:</td><td>
        <asp:CheckBoxList ID="chklanguage" runat="server"
            RepeatDirection="Horizontal">
        <asp:ListItem Text="English" Value="0"></asp:ListItem>
        <asp:ListItem Text="Hindi" Value="1"></asp:ListItem>
        <asp:ListItem>Punjabi</asp:ListItem>
        <asp:ListItem>German</asp:ListItem>
    </asp:CheckBoxList></td></tr>
                        <tr>&nbsp;</tr>
                    <tr><td>&nbsp;</td><td>
                        <asp:Button ID="btnsubmit" runat="server" Text="Submit"/></td></tr>
    </table>

Keep the below given Jquery in between Head Tag (Select minimum Two Language):

   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript" language="javascript">
            $(document).ready(function () {
                $('#btnsubmit').click(function () {
                    //validate only for one value
                    //if ($('#chklanguage input:checked').length > 0)
                    if ($('#chklanguage input:checked').length > 1) {
                        return true;
                    }
                    else {
                        alert('Select atleast two Language')
                        return false;
                    }
                })
            });
</script>

Run the project and check the result.

Is it helpful?


If yes post your comment to admire my work. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.