Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Thursday, 23 April 2015

Introduction:

In this article I will explain how to disable submit button after click or submit. When the Submit button is clicked, the JavaScript “onbeforeunload” event handler is triggered.

Introduction:

In this article I will explain how to get value of Label control on server side where value of control is set by using JavaScript or Jquery.

Introduction:

In this article I will explain how to get the Text and Value of multiple selected items of ASP.Net ListBox using JavaScript and jQuery.
 

Wednesday, 22 April 2015

Introduction: 

In this article I will explain how to get dropdown selected value and text in JavaScript and jQuery .

Following Javascript is used to get value of dropdown:

Introduction: 
In this article I will explain how to validate (check) HTML Select DropDownList using JavaScript.  

The HTML Button has been assigned a JavaScript OnClick event handler. When the Button is clicked, the Validate JavaScript function is executed,  if the selected value matches the value of the default item then an error message is displayed using JavaScript alert message box.

Friday, 17 April 2015

Introduction

In this article I will explain how to use generate year dropdown dynamically in JavaScript or jQuery generate years dropdown dynamically.


Following  JQuery script is used to generate year dropdown dynamically:

<script type="text/javascript">
    $(function () {
        var noofyears = 100; // Change to whatever you want
        var thisYear = (new Date()).getFullYear();
        for (var i = 0; i <= noofyears; i++) {
            var year = thisYear - i;
            $('<option>', { value: year, text: year }).appendTo("#ddlyear");
        }
    });
</script>

Full Source Code for sample Application:
Design your Page as given Below:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Generate years for dropdown</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
    $(function () {
        var noofyears = 100; // Change to whatever you want
        var thisYear = (new Date()).getFullYear();
        for (var i = 0; i <= noofyears; i++) {
            var year = thisYear - i;
            $('<option>', { value: year, text: year }).appendTo("#ddlyear");
        }
    });
</script>
</head>
<body>
<form id="form1">
 <fieldset style="width:250px">
    <legend><strong>Generate years for dropdown</strong></legend>
<div>
<br />
Select year: <select id="ddlyear"></select>
<br><br />
</div>
</fieldset>
</form>
</body>

</html>

Introduction: 
   
In this Article I will explain how to show 
jQuery UI date picker with Month Year dropdown Options. In this example I will show only month and year, but we can also show date.

Introduction:

In this article I will explain how to bind data to dropdownlist in gridview
 in asp.net using dataset. This is the common requirement while working with gridview to populate dropdown list inside the gridview.

Thursday, 16 April 2015

Introduction

In this article I will explain how to redirect user to another web page using jQuery or JavaScript. By using location object in jQuery or JavaScript we can redirect user to another web page.  

Introduction: 

In this article I will explain how to get stored procedure’s last modified date in 
SQL server 2008.

Following query is used to get stored procedures last modified date:

SELECT name, create_date, modify_date FROM sys.objects WHERE type = 'P'

Result: 


















Get specific procedure modified date:

SELECT name, create_date, modify_date FROM sys.objects WHERE type = 'P' AND name like 'DeleteEmployee'


Result:





Introduction: 

Some time while working in ASP.NET it is needed to find out the value or access the value of controls placed in footer. This can be done by using Javascript code. 

Tuesday, 14 April 2015

Introduction:
Sometime it is need to export data to excel from gridview or datatable. We can export data through code in asp.net (using C# & vb.net).


Introduction: 

In this Article I will explain how to show or display sum of columns total in gridview footer using asp.net in c#, vb.net.

Introduction: 

In this article I will explain 
SQL server query to get list of all tables in database or get list of all the tables in SQL server 2008 database.


Monday, 13 April 2015

Introduction

In this article, I will explain how to bind data to gridview in asp.net using dataset with example using c#, vb.net .
Introduction

Paging in gridview is very important concept in case of large data. If data is large, it is not possible to show data in single page. So in that case we will use paging to break data in no of pages. Pageindexchanging event of gridview is used for paging.
Introduction:

In this article I will explain n how to set gridview column width in Asp.Net dynamically using c# and vb.net. There are many methods by using them we can set width dynamically.
I have discussed three methods:

Method 1:

In case we are using Bound Fields (set  AutoGenerateColumns="false")  then we can set the columns width by using ItemStyle-Width property like as shown below

<asp:GridView runat="server" ID="gvrecords"  AutoGenerateColumns="false"
HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="White" >
<Columns>
<asp:BoundField DataField="UserName" HeaderText="UserName" ItemStyle-Width="50px" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" ItemStyle-Width="50px" />
<asp:BoundField DataField="LastName" HeaderText="LastName"  ItemStyle-Width="50px" />
<asp:BoundField DataField="Location" HeaderText="Location" ItemStyle-Width="50px" />
</Columns>
</asp:GridView>

Method 2:

If we binding columns dynamically then we can set width of columns dynamically by using following code:
C# Code

protected void GrdView_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
grdListings.Columns[1].ItemStyle.Width = 50;
grdListings.Columns[2].ItemStyle.Width = 150;
}
}

VB.NET Code

Protected Sub GrdView_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
grdListings.Columns(1).ItemStyle.Width = 50
grdListings.Columns(2).ItemStyle.Width = 150
End If
End Sub

Method 3:

Third method is using CSS. Using CSS we can set width of the columns:
<style type="text/css">
.columnscss
{
width:150px;
font-weight:bold;
font-family:Verdana;
}
</style>

Once we create css class in aspx then we need to write the following code in code behind

C# Code

protected void GrdView_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i > e.Row.Cells.Count; i++)
{
e.Row.Cells[i].CssClass = "columnscss";
}
}
}

VB.NET Code

Protected Sub GrdView_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim i As Integer = 0
While i > e.Row.Cells.Count
e.Row.Cells(i).CssClass = "columnscss"
i += 1
End While
End If
End Sub