How to hide generated javascript file in visual studio code

In this post I am going to show you a cool trick in visual studio code. Let's suppose you are writing typescript code in visual studio code and you want to hide generated javascript code.

Create .vscode folder in your folder and then create settings.json file and paste following code

{ "files.exclude": { "node_modules":true, "**/.git": true, "**/.DS_Store": true, "**/*.js.map": true, "**/*.js": {"when": "$(basename).ts"}     } }

How To Call .net Webservice using Javascript

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
    public Service () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld(string strName) {
        return "Hello" +strName;
    }
   
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Untitled Page</title>

    <script type="text/javascript"> function sendDataAsXML_SOAP() {
   var req_params = "", url = "", number = 0, type = "";
   /* Configure Parameters */
   url = "http://localhost/TestWebservice/Service.asmx";
   user = document.getElementById("Text1").value;
  
   req_params = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><HelloWorld >";
   req_params = req_params + "<strName>" + user + "</strName>";
   req_params = req_params + "</HelloWorld></soap:Body></soap:Envelope>";
   alert(req_params);
   /* Send XML/SOAP Request To Web Service Using Browser's Javascript DOM */
   try {
      ajax_request = new XMLHttpRequest();
      }
   catch (trymicrosoft) {
      try {
         ajax_request = new ActiveXObject("Msxml2.XMLHTTP");
         }
      catch (othermicrosoft) {
         try {
            ajax_request = new ActiveXObject("Microsoft.XMLHTTP");
            }
         catch (failed) {
            ajax_request = false;
            }
         }
      }
   ajax_request.open("POST", url, true);
   ajax_request.setRequestHeader("Content-Type", "text/xml;charset=utf-8");
   ajax_request.onreadystatechange = receiveXML_SOAPData;
   ajax_request.send(req_params);
   }

function receiveXML_SOAPData() {
   if (ajax_request.readyState == 4) {
      if (ajax_request.status == 200) {
         /* Parse The Response Data */
         //result.innerText = ajax_request.responseText;
         alert(ajax_request.responseText);
        
         }
      }
   }

    </script>

</head>
<body>
    <form action="#">
        <input type="text" id="Text1" />
        <input type="button" onclick="sendDataAsXML_SOAP();" value="Call WebService" />
    </form>
</body>
</html>

Comments

  1. It works in Internet Explorer , but not in Firefox

    pls send me what to do in firefox for getting response.

    my mail id is - kjhaveri@agileinfoways.com

    ReplyDelete
  2. Good, simple example!

    ReplyDelete
  3. how to get result as "Hello" +strName;

    ReplyDelete
  4. it doesent work!!! plz help

    ReplyDelete
  5. I can not get it to work in IE or fox.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to get cell value of gridview using JQUERY

how to convert web page to pdf

Export Html to Pdf using iTextSharp(GridView)