Showing posts from May, 2008

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, "**/*": true, "**/*.js": {"when": "$(basename).ts"}     } }

How To Read Embedded Resource File

state.cs using System; using System.Collections.Generic; using System.Text; namespace EmbeddedResource.Library { publicclass State { privatestring _name; privatestring abbreviation; publicstring Abbreviation { get { return abbreviation; } set { abbreviation = value; } } publicstring Name { get { return _name; } set { _name = value; } } } } StatesCollection.cs using System; using System.Collections.Generic; using System.Text; using System.Xml; using System.Reflection; using System.Collections; namespace EmbeddedResource.Library { publicclass StatesCollection : System.Collections.Generic.List<State> { private StatesCollection() { } privatestatic StatesCollection _southernStates = null; publicstatic StatesCollection SouthernStates { get { if (_southernStates == null) …

Parsing Comma-Separated Values or CSV files into a DataTable using Regular Expressions

Sometimes, you find the need to parse CSV files dynamically into a DataTable. CSV files can be simple or complex. The simple CSV file would just have the fields separated by commas. Complexity comes in when the data itself has embedded commas, quotes or line breaks. This solution, written in C#, and using the .NET Framework's Regular Expression object can handle such complex data. This has been tested to work with CSV formatted files saved from Microsoft Excel. To begin with, make sure that you have the following namespaces:using System.Data; using System.IO; using System.Text.RegularExpressions; Next, we build a function that parses any CSV input string into a DataTable: publicstatic DataTable ParseCSV(string inputString) { DataTable dt = new DataTable(); // declare the Regular Expression that will match versus the input string Regex re = new Regex("((?<field>[^\",\\r\\n]+)|\"(?<field>([^\"]|\"\")+)\")(,|(?<rowbreak…

GridView UpdatePanel and Javascript

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewScript.aspx.cs" Inherits="GridViewScript" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"""><htmlxmlns=""><headid="Head1"runat="server"><title>Untitled Page</title><scripttype="text/javascript">function checkCheckBoxes() { alert('There are ' + checkBoxes.length + 'checkboxes'); for(i=0;i<checkBoxes.length;i++) { var cb=document.getElementById(checkBoxes[i]); if(cb.checked) { alert('CheckBox on row ' + (i + 1) + ' is checked!' ); } } } </script></head><body><formid="form1"runat="server"><div><asp:S…

Create Dynamic Control using Repeater and List

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

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"
<title>Untitled Page</title>

How To Read XML Using Javascript

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

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"

void Page_Load()
if (Request.QueryString["sendData"] != null &&
Request.QueryString["sendData"] == "ok")
string xml = "<book title=\"ASP.NET Code Book\" author=\"Blog\">" +
"<chapters><chapter number=\"1\" title=\"Introduction\" />" +
"<chapter number=\"2\" title=\"JavaScript\" /><chapter number=\"3\" title=\"Ajax\" />" +
"<chapter number=\"4\" title=\"WPF\" /></chapters></book>";
Response.ContentType = "text/xml";

<html xmlns="htt…

How To Join Two TextBox Values Using Javascript

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AutoName.aspx.cs" Inherits="AutoName" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN"""><htmlxmlns=""><headid="Head1"runat="server"><title>Untitled Page</title></head><body><formid="form1"runat="server"><div><asp:TextBoxID="firstName"runat="server"onkeyup="autoname( );"Text="First"/><asp:TextBoxID="lastName"runat="server"onkeyup="autoname( );"Text="Last"/><asp:TextBoxID="fullName"runat="server"Text=""/></div></form><scripttype="text/javascript">function autoname( ) { var temp = document.getElementById( &quo…