Posts

Showing posts from March, 2014

How to create PDF document in ASP.NET with C# using iTextSharp

In this blog I am going to explain how to create PDF document in ASP.NET using iTextSharp. First we have to download iTextSharp.dll class library and include to our project. You can download iTextSharp.dll class library here:: http://sourceforge.net/projects/itextsharp/ Then open your project and include that iTextSharp.dll class library. In Designer Source page just add a Gridview and button. Here i have added a button for generating pdf, an image source and a Gridview for storing data :: <div> <asp:Image ID="Image1" runat="server" Width="100%"             ImageUrl="https://www.google.co.in/images/srpr/logo11w.png"             Height="100%" /> </div>  <div>         <asp:GridView ID="gvDetails" runat="server" AlternatingRowStyle-BackColor="#FFFFCC">         ...

Code for Export data to excel, Sorting, Filtering and Paging GridView data in Aps.Net- c#

Place the whole code in .aspx page <%@ Page Language="C#" AutoEventWireup="true" CodeFile="NewGridTest.aspx.cs" Inherits="NewGridTest"  EnableEventValidation="false"%> <!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 runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">    <div>         <div>             <asp:GridView ID="gvDetails" runat="server" AutoGenerateColumns="False"                 Font-Names="Verdana" AllowPaging="True" AlternatingRowStyle-BackColor="#EFF3FB" AllowSorting="True" PageSize="5" Width="40%"     ...

Code for Data Export from GridView to Excel in Asp.Net- c#

In this blog, I am going to show how we could export our data from a gridview to excel sheet in Asp.net- c# (Export to excel data) First of all, just take a gridview on your design page and fill data as below :: protected void Page_Load(object sender, EventArgs e)     {         if (!IsPostBack)         {            BindGrid();         }     }     protected void BindGrid()     {         gvDetails.DataSource = this.getData();         gvDetails.DataBind();     }     private DataTable getData()     {         DataTable dt = new DataTable();         dt.Columns.Add("UserId", ...

How to show enlarge image when mouse hover on image or link in Asp.Net(c#) using JavaScript

Image
In this blog i am going to show we could show enlarded image when hover on Link or an image like we see on any e-commerce website. First of all right click on your application >> Select Add New Folder and Give name as images >> Once folder created place some images in folder to show preview of images when hover on link using JQuery in asp.net. After completion of folder creation and insertion of images in folder write the following code in your aspx page :: Put the below code inside the <heaD> tag::  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script> <script type="text/javascript" language="javascript">     $(document).ready(function () {         ShowPreview();     });     // Configuration of the x and y offsets     function ShowPreview() {      ...

Code for designing and developing a very famous game- Tic Tac Toe or say Simply Cross- zero game with the help of JavaScript

Image
In this blog i am going to share a very interesting thing. Yes, you are right i am going to show you how we could make a game very easily with the help of JavaScript.                                All of us have heard about this game and in our childhood days almost almost all of us had played Tic-Tac-Toe game or in simple words Cross-zero game. But now we'll play it on our PC and that too developed by ourselves. So you seems excited to develop it. You don't require to take any stress just copy and paste the whole code and start playing... :) First of all copy paste the whole JavaScript code inside the <head> tag given below :: <script type="text/javascript">     //Simple Tic Tac Toe Game:     //board is a 3 by 3, two dimensional array of numbers. board = new Array(new Array(0, 0, 0), new Array(0, 0, 0), new Array(0, 0, 0)) //integer points/values i...

Code for showing Attractive Validation hints and Alert Message using JavaScript

Image
In this blog i am going to show how to alert users with message in a very attractive way while entering values in textbox areas (i.e. Validation Hint) and how to get values from HTML controls and show those values in alert message through JavaScript.       Validation Hints is a simple script that aides in form validation. It makes sure that password and username fields are the specified length, and can even validate against regular expressions. Small and handy. First of add all the functions and the CSS code given below inside the <head> tag ::   <style type="text/css"> form { width:500px; border:1px solid #ccc; } fieldset { border:0; padding:10px; margin:10px; position:relative; } label { display:block; font:normal 12px/17px verdana; } input {width:160px;} span.hint { font:normal 11px/14px verdana; background:#eee url(images/bg-span-hint-gray.gif) no-repeat top left; color:#444; border:1px solid #888; padding:5px 5px 5px 40p...

How to access different controls within the GridView control in Asp.Net(C#)

In this blog i am going to show you how to find different controls within the GridView control e.g. TextBox control, Button control, ListBox control, DropDown, etc. On the Button click event, I will print the values that are either entered (TextBox) or selected (DropDownList and ListBox). Let's see how this can be done :: protected void Button1_Click(object sender, EventArgs e) {     // Iterates through the rows of the GridView control     foreach (GridViewRow row in GridView1.Rows)     {         // Selects the text from the TextBox         // which is inside the GridView control         string textBoxText = ((TextBox)row.FindControl("TextBox1")).Text;         Response.Write(textBoxText);               // Selects the text from the DropDownList         // which is inside the GridView control     ...

How to show empty gridview when no data is available to display in Asp.Net- C#

Image
In this blog i am going to describe how we could add a custom message in GridView in Asp.Net(c#) in case data is not available in database/ datatable, etc. through code window (Although GridView provides direct property for this when data not available and users could use that property easily but in many case programmer wants to add message through code) First of all in the design page(.aspx) place a GridView control as: <div>         <asp:GridView ID="TestGrid" runat="server">         </asp:GridView> </div>  I used a very simple gridview without any styl& design, just to show message when data not available through code window. Now, in the code behind file(.aspx.cs) write the code as :: protected void Page_Load(object sender, EventArgs e)     {         if (!IsPostBack)         {             FillTestGrid(); ...
go to top image