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 Handle an async postback timeout in ASP.NET

<%@ Page Language="C#" AutoEventWireup="true" %>

<script runat="server">
   protected void slow_postback(object sender, EventArgs e)
   {
       // ten seconds is overkill... we timeout after one second (see ScriptManager below) 
       System.Threading.Thread.Sleep(10000);
   }
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
   <title>Handling an async postback timeout</title>
</head>
<body>
   <form id="form1" runat="server">
       <!-- This sets the timeout on async postbacks (i.e. UpdatePanel refreshes) to one second -->
       <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="1" />
       <asp:UpdatePanel ID="UpdatePanel1" runat="server">
           <ContentTemplate>
               <asp:Button ID="Button1" runat="server" Text="Fast postback - no timeout" /> <br />
               <asp:Button ID="Button2" runat="server"
                Text="Slow postback - times out after one second"
 OnClick="slow_postback" /> <br />
               Last updated: <%= DateTime.Now %>
           </ContentTemplate>
       </asp:UpdatePanel>
   </form>
</body>

<script type="text/javascript">
   Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function (sender, args) {
       if (args.get_error() && args.get_error().name ===
'Sys.WebForms.PageRequestManagerTimeoutException') {
           alert('Caught a timeout!');
           // remember to set errorHandled = true to keep from getting a
popup from the AJAX library itself 
           args.set_errorHandled(true);
       }
   });
</script>
</html>

Comments

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)