Wednesday, 18 September 2013

Select/Deselect multiple check boxes using jQuery

HTML Code : 

<div><input id="chkAll" type="checkbox"/>Check all Boxes</div><br />
<table id="tblBoxes">
      <tr><td><input id="Checkbox1" type="checkbox" class="chkA"/></td><td>Check box - 1</td></tr>
      <tr><td><input id="Checkbox2" type="checkbox" class="chkA"/></td><td>Check box - 2</td></tr>
      <tr><td><input id="Checkbox3" type="checkbox" class="chkA"/></td><td>Check box - 3</td></tr>
      <tr><td><input id="Checkbox4" type="checkbox" class="chkA"/></td><td>Check box - 4</td></tr>
      <tr><td><input id="Checkbox5" type="checkbox" class="chkA"/></td><td>Check box - 5</td></tr>
</table>

Script Code : 

 $(document).ready(function () { 
     $("#chkAll").click(function(event) {
         if($('#chkAll').prop('checked'))
             $('.chkA').prop('checked', true);
         else
             $('.chkA').prop('checked', false);       
     });
     

 });


Check for online Demo 

note : add required jQuery files.

Thursday, 22 August 2013

Calling .aspx page in JQuery popup message

       1)      Download the below JQuery files from JQuery.com and paste the  below JQuery files to JQScripts folder
        jquery-ui-1.9.1.custom.min.js
        jquery-latest.js

        2)      Do the same for following file also
         jquery-ui-1.9.1.custom.css

         3)      Copy and paste the “images” folder to Css

          4)      Load the script and CSS files, in which page you want to display JQuery Model pop up
<script src="JQScripts/jquery-latest.js" type="text/javascript"></script>
<script type ="text/javascript" src="JQScripts/jquery-ui-1.9.1.custom.min.js"></script>

<link href="Css/jquery-ui-1.9.1.custom.css" rel="stylesheet" type="text/css" />

         5)      Add the following script in script tag of <head> section

$('#openDialog').dialog({
                                                                                title: "Rate plan - More info",
                                                                                //show: "blind",
                                                                                hide: "explode",
                                                                                modal: true,
                                                                                width: 800,
                                                                                height: 250,
                                                                                top: 15
                                                                    });

                                                                    $('#openDialog').load(url, function () {                  
                                                                                $(this).dialog('open');
                                                                    });                       

       6 )      Add the html code in between <form> </form> tag or <body>  </body> tag
<div id="openDialog" style="top:15px !important;"></div>

Thursday, 6 June 2013

Compare two dates in .NET based on Day



Compare two DateTimes:

DateTime date1=Convert.ToDateTime("06-01-2013");
DateTime date1=Convert.ToDateTime("06-01-2013");

int days = DateTime.Compare(date1, date2);

* days > 0      date1  is greaterthan date2
* days = 0      date1 and d2 are equal
* days < 0      date1 is lesserthan date2

But the problem with DateTime is it will compare with exact values with time also.


Compare only two Dates :

TimeSpan ts= date1 - date2;

TimeSpan will return exact days & hours and we need to extract the days from it and we can compare.

* ts.Days > 0      date1  is greaterthan date2
* ts.Days= 0       date1 and d2 are equal
* ts.Days <  0     date1 is lesserthan date2  

Here ts.Days will give you exact days..

Friday, 4 January 2013

sending SMS from .Net using Way2SMS Gateway



Description: you can send free sms by using way2sms gateway from your .Net Application. Here, Just you need to give your login credentials of way2sms.com from your app.

Implementation:
Step 1: Design you UI based on your requirement. Here for your reference I took two input  textbox’s and which one is for accepting mobile number and another one is for message.


Step 2: Go to code window and define 4 local variables of string type, which are username,Password,Message and Mobile number.
Step 3: Now Download way2sms dll file from source click here. And save it into your local drive.

Step4: open your project and select Add Reference in Solution Explorer and select browse option and select smsClient.dll file

Step5 : Go to your code and write following code in button click event.
        
        SendSms newSms = new SendSms();
       string status = string.Empty;
                status = newSms.send(userName, passWord, txtMsg.Text, txtMobileNo.Text);
        if (status == "1")
        {
            lblResult.Text = "Message sent successfully";
        }
        else
            lblResult.Text = status;

Step 6: send() of SendSms class is required 4parameters as follows,

public string send(string uid, string password, string message, string no);

Step 7 : Now you can enjoy to send SMS. and you can find full source code here