Posts

Showing posts from 2009

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 fill PDF form field using ITextSharp

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title></head><body><formid="form1"runat="server"><div></div><asp:ButtonID="Button1"runat="server"Text="Fill Pdf"OnClick="Button1_Click"/></form></body></html>using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using iTextSharp.text.pdf; using System.IO; publicpartialclass _Default : System.Web.UI.Page { protectedvoid Page_Load(object sender, EventArgs e) { } privatevoid fillForm…

How To Render the content of webcontrol as html

Image
<%@ Page Language="C#" ValidateRequest="false" EnableEventValidation="false" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title></head><body><formid="form1"runat="server"><div><table><tr><td><asp:GridViewID="grdDemo"runat="server"></asp:GridView></td><td><asp:DropDownListID="ddlDemo"runat="server"><asp:ListItemText="Cat1"Value="1"></asp:ListItem><asp:ListItemText="Cat1"Value="1"></asp:ListItem><asp:ListItemText="Cat1"Value="1&q…

How To Create TextBox Dynamically using Jquery t and Read Control Value In Code Behind

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title><scriptsrc="Scripts/jquery-1.3.2.js"type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $("#btnOfficial").click(function() { var hdValue = $("#theValue"); var num = ($("#theValue").val() - 1) + 2; hdValue.val(num); var newDiv = $(document.createElement('div')).attr("id", 'my' + num + 'Div'); newDiv.after().html('<input type=…

Dynamic Drag’n Drop With jQuery And ASP.NET

Image
In thi post i will show how to drag’n drop & saving the new positions to the database. Here is, how it is done by usingjQuery &jQuery UI: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default2" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title><scriptsrc="Scripts/jquery-1.3.2.js"type="text/javascript"></script> <script type="text/javascript" src="Scripts/jquery-ui-1.7.2.custom.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#contentLeft ul").sortable({ opacity: 0.6, cursor: 'move', update: function() { var orde…

How To Use Jquery Google Chart In asp.net

Image
In this post i will show how to add Jquery Google Chart in asp.net. Click Here to download Jquery Google Chart Plugin<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Chart.aspx.cs" Inherits="Chart" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>jQuery Google Chart Demo</title><scriptsrc="jquery-1.3.2.min.js"type="text/javascript"></script> <script src="jgcharts.pack.js" type="text/javascript"></script> <link href="Style/style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $(document).ready(function() { $("#btnCreate").click(function() { …

How to use Generic Delegate in C#

Action<T>:Encapsulates a method that takes a single parameter and does not return a value. Action<T1,T2>:Encapsulates a method that has two parameters and does not return a value. Action<T1,T2,T3>:Encapsulates a method that has three and does not return a value. Action<T1,T2,T3,T4>:Encapsulates a method that has four and does not return a value. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GenericDelegate { class Program { static void Main(string[] args) { //Action<T> Action print = s => Console.WriteLine(s); string message = "Hello World"; print(message); //Action<T1,T2> Action add = (x, y) => Console.WriteLine(x+y); add(1, 2); } } }

How To Add Jquery Plugin Tablesorter in Gridview

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title><scriptsrc="Scripts/jquery-1.3.2.js"type="text/javascript"></script> <script src="Scripts/Jquery.tablesorter.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $("#grdStudent").tablesorter(); } ); </script></head><body><formid="form1"runat="server"><div><asp:GridViewID="grdStudent"runat="server"UseAccessibleHeader="true…

Cascading Dropdownlist using JQuery and WebService

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title><scriptsrc="Scripts/jquery-1.2.6.js"type="text/javascript"></script> <script type="text/javascript"> $().ready(function() { $.ajax({ type: "POST", url: "WebService.asmx/GetStates", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { BindStateddl(msg.d) } }); //Fetch related city …

How To display Image using Linq To Sql

Image
Default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title></title></head><body><formid="form1"runat="server"><div><asp:GridViewID="grdCategories"runat="server"DataKeyNames="CategoryID"Width="600px"AutoGenerateColumns="false"><Columns><asp:BoundFieldDataField="CategoryID"HeaderText="CategoryID"/><asp:BoundFieldDataField="CategoryName"HeaderText="CategoryName"/><asp:TemplateField><ItemTemplate><asp:ImageID="Image1"runat="server"Image…

CSV Parser

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Collections; using System.Reflection; namespace CSVProvider { class Program { static void Main(string[] args) { CSVProvider csv = new CSVProvider(@"C:\Student.txt"); foreach (var item in csv.OfType()) { Console.WriteLine(item.ToString()); } Console.ReadLine(); } } public class Student { public int ID { get; set; } public string FullName { get; set; } public int Age { get; set; } public override string ToString() { return string.Format(@"ID={0} FullNam={1} Age={2}", ID, FullName, Age); } } public class CSVProvider : IDisposable, IEnumerable, IEnumerator { private string fileName = default(string); FileStream fsObject = null; StreamRead…

How To Use Web Service Behavior in an ASP.NET Page To Invoke the Web service

Image
If you are using Microsoft IE 5 or later, you can use the behavior/HTML-Component "WebService" to access a Web service. The "WebService" behavior communicates with Web services over HTTP using Simple Object Access Protocol (SOAP).To use the "WebService" behavior, you must attach it to an element using the STYLE attribute. How To Use Web Service Behavior in an ASP.NET Page To Invoke the Web service The first step in using the Web service behavior in a Web page is embedding it using syntax similar to this: <divid="service"style="BEHAVIOR:url(webservice.htc)"></div> The above code relies on the behavior functionality built into IE 5 (and higher) to identify the location of the JavaScript file that will be used to call Web services. As discussed previously, the webservice.htc file should be available on the same folder as that of the Web page. It is important to note that the loading of the behavior file occurs on the clie…

Event Bubbling in asp.net

Image
UCBubble.ascx <%@ Control Language="C#" AutoEventWireup="true" CodeFile="UCBubble.ascx.cs" Inherits="UCBubble" %><fieldset><legend><labelfor="TextBox1"> Enter Text and Press Tab</label><asp:TextBoxID="TextBox1"runat="server"/><labelfor="ddlColor"> Select Color</label><asp:DropDownListAutoPostBack="true"ID="ddlColor"runat="server"><asp:ListItemText="Red"Value="Red"></asp:ListItem><asp:ListItemText="Green"Value="Green"></asp:ListItem></asp:DropDownList></legend></fieldset> UCBubble.ascx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; publicpartialclass UCBubble : System.Web.UI.UserControl { publicstring SelectedIndex …

How to prevent users from running more than one instance of our program.

By using Mutex object you can prevent users from running more than one instance of the application. Check out this code snippet using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace SingleInstacle { publicclass Program { staticvoid Main(string[] args) { bool createdNew = false; Mutex mutex = new Mutex(true, "SingleInstance", out createdNew); if (createdNew) { Console.WriteLine("Hello world"); } else { Console.WriteLine("You can only run a single instance of this app!"); } Console.ReadLine(); } } }

Microsoft Ajax Client Template

Image
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>Ajax Client Side Template</title><scriptsrc="Scripts/MicrosoftAjax.debug.js"type="text/javascript"></script> <script src="Scripts/MicrosoftAjaxTemplates.debug.js" type="text/javascript"></script> <script src="Scripts/MicrosoftAjaxAdoNet.debug.js" type="text/javascript"></script> <style type="text/css"> .sys-template { display: none; } </style> <script type="text/javascript"> function LoadData() { …