Rss Feed Like Us on facebook Google Plus

May 10, 2014

Call WebService using JQuery and HTML : Asp.Net

This article is all about Calling a WebService (asmx) in HTML Page using jquery. to call a webservice first thing to know about a webservice
  • Web services are application components
  • Web services communicate using open protocols
  • Web services are self-contained and self-describing
  • Web services can be discovered using UDDI
  • Web services can be used by other applications
  • HTTP and XML is the basis for Web services

Webservices transfers data to application in XML, JSON and Text Format as well as JSON object.

One important distinction is what I mean by a JSON object and JSON format.  A JSON object is an object that can be used by javascript
var o = {data: 'value'};
alert (o.data); // this works as o is an object
JSON format is simply a literal string that can be turned into a JSON object if we parse it
var f = "{data: 'value'}";
alert (f.data); // this won't work as f is just a string and string doesn't have a data property
EXAMPLE

WEB SERVICE
[WebMethod]
public string SayHello(string firstName, string lastName)
{
    return "Hello " + firstName + " " + lastName;
}

[WebMethod]
public string SayHelloJson(string firstName, string lastName)
{
    var data = new { Greeting = "Hello", Name = firstName + " " + lastName };

    // We are using an anonymous object above, but we could use a typed one too (SayHello class is defined below)
    // SayHello data = new SayHello { Greeting = "Hello", Name = firstName + " " + lastName };

    System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();

    return js.Serialize(data);
}

[WebMethod]
public SayHello SayHelloObject(string firstName, string lastName)
{
    SayHello o = new SayHello();
    o.Greeting = "Hello";
    o.Name = firstName + " " + lastName;

    return o;
}
"SayHello" returns a string "SayHelloJson" returns a string that is an object in JSON format "SayHelloObject" returns an object.  The SayHello class is here
public class SayHello
{
    public string Greeting { get; set; }
    public string Name { get; set; }
}
HTML


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Hello World</title>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div><br />Example A</div>
    <div id="searchresultsA"></div>
    <div><br />Example B</div>
    <div id="searchresultsB"></div>
    <div><br />Example C</div>
    <div id="searchresultsC"></div>
    <div><br />Example D</div>
    <div id="searchresultsD"></div>
    <div><br />Example E</div>
    <div id="searchresultsE"></div>

    <script type="text/javascript">
              // Example A - call a function that returns a string.
              // Params are sent as form-encoded, data that comes back is text
              $(document).ready(function () {
              $.ajax({
                type: "POST",
                url: "MyWebService.asmx/SayHello",
                data: "firstName=Aidy&lastName=F", 
                dataType: "text", 
                success: function (data) {
                    $("#searchresultsA").html(data);
                }
            });

            // Example B - call a function that returns a string.
            // Params are sent in JSON format, data that comes back is JSON
            $.ajax({
                type: "POST",
                url: "MyWebService.asmx/SayHello",
                data: "{firstName:'Aidy', lastName:'F'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json", 
                success: function (data) {
                    $("#searchresultsB").html(data.d);
                }
            });

            // Example C - call a function that returns a string.
            // Params are sent as a JSON object, data that comes back is text
            $.ajax({
                type: "POST",
                url: "MyWebService.asmx/SayHello",
                data: { firstName: 'Aidy', lastName: 'F' },
                contentType: "application/x-www-form-urlencoded; charset=UTF-8",
                dataType: "text",
                success: function (data) {
                    $("#searchresultsC").html(data); 
                }
            });

            // Example D - call a function that returns a string that is an object in JSON format.
            // Params are sent in JSON format, data that comes back is a string that represents an object in JSON format
            $.ajax({
                type: "POST",
                url: "MyWebService.asmx/SayHelloJson",
                data: "{ firstName: 'Aidy', lastName: 'F' }",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var myData = JSON.parse(data.d); 
                    $("#searchresultsD").html(myData.Greeting + " " + myData.Name);
                }
            });

            // Example E - call a function that returns an object.  .net will serialise the object as JSON for us.
            // Params are sent in JSON format, data that comes back is a JSON object
            $.ajax({
                type: "POST",
                url: "MyWebService.asmx/SayHelloObject",
                data: "{ firstName: 'Aidy', lastName: 'F' }",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var myData = data.d; 
                    $("#searchresultsE").html(myData.Greeting + " " + myData.Name);
                }
            });
        });
    </script>

    </form>
</body>
</html>
Read More

March 21, 2014

Install WhatsApp in Nokia X

when i bought Nokia X , i am surprised there is no WhatsApp and no direct option to install it. so i found 2 ways to install WhatsApp in Nokia-X. checkout below.


1st Way

The idea came from the store search itself when it was pointing to 1MobileStore, a popular Android store, which has the official WhatsApp for android devices. Below is a video explaining how I installed it.

Follow the steps to get the WhatsApp:

  • Search in Nokia Store for app named as “1MobileStore”.
  • Install it and launch.
  • Now since this app itself is a store, make a search again for WhatsApp.
  • The first result should list the WhatsApp, officially from WhatsApp Inc. Take a look at ratings to figure if that’s correct.
  • Install and start using after following up the basic setup.
  • In case, you get an error during installation where it concerns about security. Turn on installation from unknown sources. You will get the option to get there right when the error shows up.
  • Instead of sending out verification code to your number, it will use SMS to verify.


















2nd Way

Download WhatsApp directly from its website. open website in your Nokia - X browser. i will redirect to android-store

See picture :



Read More

February 20, 2014

Style your button with transform and transition : CSS3

Style up your button with CSS3 transitions and transform. i'm going to give a demo to use these properties. below some basic information of Transition and Transform
Transform :
The transform property applies a 2D or 3D transformation to an element. This property allows you to rotate, scale, move, skew, etc., elements.

transform: none|transform-functions|initial|inherit;

Transition :
CSS3 transitions are effects that let an element gradually change from one style to another.
To do this, you must specify two things:
  • Specify the CSS property you want to add an effect to
  • Specify the duration of the effect.
transition: all 1s ease-in-out;

Example with a Button


HTML :
<div>
 <button type="button" class="btn-effect">Submit</button>
</div>
CSS :
.btn-effect:before {
    background: none repeat scroll 0 0 #66B3F6;
    content: "";
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 100%;
    z-index: -1;
    color: #fff;
}
.btn-effect:after {
    background: none repeat scroll 0 0 #BFE1FB;
    content: "";
    height: 0;
    left: 50%;
    opacity: 0;
    position: absolute;
    top: 50%;
    transform: translateX(0%) translateY(-25%) rotate(45deg);
    -webkit-transform: translateX(0%) translateY(-25%) rotate(45deg);
    transition: all 0.3s ease 0s;
   -webkit-transition: all 0.3s ease 0s;
    width: 100%;
    z-index: -1;
    border: 1px solid #f4f4f4;
    left: 0;
    top: 0;
}
.btn-effect {
    border: 0.5px solid #f4f4f4;
    color: #fff;
    cursor: pointer;
    font-family: segoe ui;
    font-size: 18px;
    height: 45px;
    line-height: 18px;
    padding: 10px 40px;
    position: relative;
    font-variant: small-caps;
    transition: all 0.5s ease-in-out 0s;
    box-shadow: 1px 3px 5px 1px #aaa;
    font-size: 22px;
    overflow: hidden;
    z-index: 99;
  border-radius:5px;
}
.btn-effect:hover, .btn-effect:active {
    color: #000000 !important;
}
.btn-effect:hover:after {
    height: 215%;
    opacity: 1;
    width: 100%;
}
.btn-effect:active:after {
    height: 235%;
    opacity: 1;
}

LIVE DEMO :


Read More

January 13, 2014

GPG Dragon Version 3.35 Free Download

GPG Dragon Version 3.35 Features 

  • SC6530 &6531 Rear-Write
  • Flash Auto identify SC6531&6530 Flash 
  • Amount Adjust SPD 6820/8810 Read Flash Adjust SPD6820/8810
  • Write Flash For Bin 
  • File Adjust SPD6820/8810 Write Flash For PAC File
  • Add New Flash tar

Format Support -
  • All SPD android
  • Add MTK Android New NAND Flash Support
  • Added More chips information in the software!
ABOUT GPG DRAGON
  1. Gpgdragon box supports all china mobile
  2. Gpgdragon box supports china mobile pinfinding
  3. Gpgdragon box support zte and huawei pinfinding and repair
  4. Gpgdragon software is easy use and has constant updates.

Download Now...
Read More

December 10, 2013

Object Error in Internet Explorer (IE- 7,8,9,10,11)


While opening Internet Explorer you are getting the Object Error in a popup window, this error may come while opening a new web page or between surfing a website.


Issues:
1.most add-ons are not compatible with the 64 bit version of ie
2.Many dysfunctional addons from various utilities will effect the internet explorer
3.Security suites Privacy features/ Toolbars 
4. unwanted addons ,toolbars

Solution:

Here are the few steps to resolve this problem, please follow these steps to automatically resolve it.

Step 1.  Uninstall Unwanted Toolbars from add/remove program

Example:-
privacy safe gaurd,Social Privacy,unfriend checker,Price peep today,Coupon amazing,We-Care Toolbar

Step 2. Disable all addons except from Microsoft

goto Tools >> Manage Add-Ons
or you can use this MS fixit utility.

Step 3. Reset Internet Browser Setting

goto Tools >> Internet options >> Advanced tab 

Click on Reset Button and Restore Advance Setting button


Restart your Browser/System then check. your problem should be resolved.


Read More

© 2011-2016 Techimpulsion All Rights Reserved.


The content is copyrighted to Tech Impulsion and may not be reproduced on other websites.