Tuesday, 31 July 2018

How to Send messages through WhatsApp Using Asp.Net PART - II

Dear all In this article i would like to emphasize How to Send messages through WhatsApp using Asp.Net PART - I.In my previous article i explained essence of articles relate to C#.Net,Asp.Net,Interview Questions,XML Related Articles and Sql Server Related articles.Let's have a Deep dive of this implementation. 


About This Implementation:
In this article i emphasized how to send an WhatsApp message in MWeb titled as How to Send messages through WhatsApp Using Asp.Net PART - II.Let's get it into it.

In this example Desktop or Website and MWeb Implementation was handled.


Source Code :



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PNVComm.aspx.cs" Inherits="PNVComm" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>How to Send Messages  through whatsapp  Using Asp.Net PART - II</title>
    <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            var MyUrls = [];
            MyUrls[0] = 'http://seoveerendra.blogspot.com/search/label/JavaScript';
            MyUrls[1] = 'http://seoveerendra.blogspot.com/search/label/ScholarShips';
            MyUrls[2] = 'http://seoveerendra.blogspot.com/search/label/NEWS';
            MyUrls[3] = 'http://seoveerendra.blogspot.com/search/label/Editorial';

            $(document).on("click", ".whatsapp", function () {
                var WMsg = '';
                $IDs = $("#tblExample input:checkbox:checked").map(function () {
                    return $(this).attr("id");
                }).get();

                for (var i = 0; i < $IDs.length; i++) {
                    var text = $IDs[i];                   
                    WMsg = WMsg + MyUrls[text.replace('chk_', '')] + "\n\r";
                }

                if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
                    var message = encodeURIComponent(WMsg);
                    var whatsapp_url = "whatsapp://send?text=" + message;
                    alert(whatsapp_url);
                    window.location.href = whatsapp_url;
                }
                else {               
                    var whatsApp_Url = "https://api.whatsapp.com/send?phone=+91XXXXXXXXXX&text=" + WMsg;
                    window.open(whatsApp_Url, '_blank');                   
                }
            });
        });

    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <table width="100%" id="tblExample">
                <tr>
                    <th>Select</th>
                    <th>Category</th>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="chk_0" />
                    </td>
                    <td>Client Side Scripting (Java Script / JQuery)</td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="chk_1" />
                    </td>
                    <td>Scholarships</td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="chk_2" />
                    </td>
                    <td>News</td>
                </tr>
                <tr>
                    <td>
                        <input type="checkbox" id="chk_3" />
                    </td>
                    <td>Editorial</td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <a class="btn ros-social ros-btn ros-btn-mob ros-whatsapp cream-tooltip btn_130px btn_60px hidden-lg hidden-md whatsapp" data-toggle="tooltip" title="" data-original-title="Share link on Whats App">
                            <img src="wa.png" />
                            Test</a>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>

No comments :

Post a Comment