Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts

Monday, 17 August 2015

In this article I will explain how to select all records in Datalist using Javascript.
When we click “Select all” checkbox, all item will get selected. If we unselect one of record, then “Select all” checkbox will get unselected.

In this article I will explain how to check all check boxes in gridview using Javascript.
When we click on header check box then all checkboxes will be checked and if one of the checkbox is unchecked then Header will also be unchecked. If we check all checkboxes then Header checkbox  will automatically checked.

Monday, 27 July 2015

In this article I will explain how to count rows of gridview using jquery in asp.net(c# or vb.net.).
In previous article I have explained how to get count of gridviews rows using javascript. In this article I will use jquery to achieve the same.

Demo:

Saturday, 25 July 2015

Introduction:

In this article I will explain how to redirect to other page after some time, ex. 5 seconds.  This can be done by using javascript or jquery.

In this article I will use JavaScript to redirect to   other page with delay.

Full Source Code For Redirect after 5 seconds:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <fieldset style="width:400px;"><legend><strong>Redirect to other Page After 5 Second Using Jquery</strong></legend>
      <br />  Click here to redirect Page&nbsp;&nbsp;&nbsp;
<input type="button" value="Redirect" onclick="DelayRedirect()" />
<br />
<br />
<div id="dvCountDown" style = "display:none">
You will be redirected after <span id = "lblCount"></span>&nbsp;seconds.
</div></fieldset>
<script type="text/javascript">
    function DelayRedirect() {
        var seconds = 5;
        var dvCountDown = document.getElementById("dvCountDown");
        var lblCount = document.getElementById("lblCount");
        dvCountDown.style.display = "block";
        lblCount.innerHTML = seconds;
        setInterval(function () {
            seconds--;
            lblCount.innerHTML = seconds;
            if (seconds == 0) {
                dvCountDown.style.display = "none";
                window.location = "http://www.maziksolutions.com/";
            }
        }, 1000);
    }
</script>
</body>

</html>

Thursday, 23 July 2015

Introduction:

In this article I will explain how upload file without clicking submit button. This can be possible by using JavaScript code.

Steps to follow:
1.      Add File Upload Control, label control and Button Control.
2.      Now Hide Label Control and set display none for Button Control.
3.      Now Write Javascript code to Trigger Submit button Click Event, which cause Postback and upload file.
4.     On Page load call Javascript function on fileupload control’s “onchange ” attribute.

Tuesday, 14 July 2015

Introduction:
Some time we need to find the position of the first occurrence of a specified value in given string. In this article I will explain how to find position of the first occurrence of a specified value using Javascript.

Thursday, 9 July 2015

Introduction:

In this article I will explain how to remove white spaces from the given string. This can be done by using code in code behind but it is time consuming. Javascript give us a easy way to remove white spaces from the string.

Following Javascript We use to remove white spaces from given string:

<script type="text/javascript">
    $(document).ready(function () {
        $('#btnFilter').click(function () {
            var str = ' Hello, World. This is Maziksolutions.'
            var newstr = str.replace(/\s/g, '') // Remove white spaces from string
            alert(newstr);
        });
    });
</script>

Source Code:
Full Source code of Sample Application:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Remove White spaces from String Using Jquery</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
</head>
<body>
<form id="form1" runat="server"><center>
<div>
String : <b>'   Hello, World. This is Maziksolutions.  '</b><br />
<br /><input type="button" id="btnFilter" value="Remove White Spaces From String" /><br /><br />
</div></center>
<script type="text/javascript">
    $(document).ready(function () {
        $('#btnFilter').click(function () {
            var str = ' Hello, World. This is Maziksolutions.'
            var newstr = str.replace(/\s/g, '') // Remove white spaces from string
            alert(newstr);
        });
    });
</script>
</form>
</body>
</html>


Use this code and check result. We can use this code in our applications.
In this article I will explain how to set different date format in Javascript. We can display date in short or long format in Javascript.
In this article we use three Label Controls to display different date formats.  We get these controls in script under Head section and set values of different format to these controls.


Following Javascript We use to display different formats:

<script type="text/javascript">
    function getdates() {
        var today = new Date()
        document.getElementById('lblDefault').innerHTML = today;
        document.getElementById('lblPrev').innerHTML = [today.getDate(), today.getMonth() + 1, today.getFullYear()].join('/');
        document.getElementById('lbldateformat').innerHTML = [today.getDate(), today.getMonth() + 1, today.getFullYear()].join('/') + ' ' + [today.getHours(), today.getMinutes(), today.getSeconds()].join(':');
    }
</script>

Source Code:
Full Source code of Sample Application:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Set Different Format In JavaScript</title>
<script type="text/javascript">
    function getdates() {
        var today = new Date()
        document.getElementById('lblDefault').innerHTML = today;
        document.getElementById('lblPrev').innerHTML = [today.getDate(), today.getMonth() + 1, today.getFullYear()].join('/');
        document.getElementById('lbldateformat').innerHTML = [today.getDate(), today.getMonth() + 1, today.getFullYear()].join('/') + ' ' + [today.getHours(), today.getMinutes(), today.getSeconds()].join(':');
    }
</script>
</head>
<body onload="getdates()">
<form id="form1">
<div>
<b>Default Date Format:</b>
<label id="lblDefault" />
</div>
<div>
<b>Date in dd mm yyyy format:</b>
<label id="lblPrev" />
</div>
<div>
<b>Date in dd mm yyyy hh:mm:ss Format:</b>
<label id="lbldateformat" />
</div>
</form>
</body>
</html>


Use this code and check result. We can use this code in our applications.