Skip to main content

Posts

How to restrict download of specified file types in asp.net

In this post i will show you how to restrict your web app so that .txt (whatever file extensions you want ) files can not be downloaded. Open your web.config file and register following setting in your web.config <system.web><httpHandlers><addverb="*"path="*.txt"type="System.Web.HttpForbiddenHandler"/></httpHandlers></system.web> For more details how to register handler in web.config check out this link

How to animate grdivew using Jquery

<%@ 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() { $('#<%=ddlCategory.ClientID %>').change(function() { var categoryid = $('#<%=ddlCategory.ClientID %>').val(); $.ajax( { type: "POST", dataType: "json", contentType: "application/json", data: "{'CategoryID':'…

GridView row double click and postback using Jquery

<%@ 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"><styletype="text/css"> .selected { background-color: Red; } </style><scriptsrc="Scripts/jquery-1.3.2.js"type="text/javascript"></script> <title></title> <script type="text/javascript"> var selected = null; $(document).ready(function(){ $("#<%=GridView1.ClientID %>").find("tr").click(function(){ $(selected).removeClass("selected"); $(this).addClass("selected"); selected = this; }); $("#<%=GridView1.Cl…

How to get cell value of gridview using JQUERY

<%@ 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() { var list = ""; $("#btnGet").click(function() { $("#<%=GridView1.ClientID %> tr").each(function() { //Skip first(header) rowif (!this.rowIndex) return; var age = $(this).find("td:last").html(); list += age + "</br>"; }); …

How To change the color of gridview row on mouseover using JQUERY

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.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"><headid="Head1"runat="server"><title></title><scriptsrc="Scripts/jquery-1.3.2.js"type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() { $("#<%=GridView1.ClientID%> tr").filter(function() { return $('td', this).length && !('table', this).length }).hover ( function() { $(this).css("background-color", "red") }, function() { $(this).css("background-…

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

<%@ 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…