Posts tagged ‘’

Hyperlinked Images in ASP.NET GridView (Open content in new page)

Solution : 1

TemplateField with Hyperlink and img Element

<asp:HyperLink runat=”server” NavigateUrl='<%# Eval(“PAGE_Or_PDF_URL”) %>’
<img src='<%# Eval(“Image_URL”) %>’ alt=”PDF IMAGE” />

Solution : 2
TemplateField with ImageButton

<asp:ImageButton runat=”server” ImageUrl='<%# Eval(“Image_URL”) %>’
PostBackUrl='<%# Eval(“Target_URL”) %>’ AlternateText=”Alternate Text” />
Solution : 3

TemplateField with Javascript

<asp:ImageButton ID=”ImageButton1″ runat=”server” ImageUrl='<%# Eval(“Image_URL”) %>’ OnClientClick='<%# String.Format (“javascript:return openTargetURL(\”{0}\”)”, Eval(“Target_URL”)) %>’ AlternateText=”Alternate Text” />


Check Transaction amount having decimal point or not

Using Below code, we can trace entered amount has decimal point or not.

AMOUNT = 500.25;

AMOUNT.ToString().IndexOf(“.”) != -1

AMOUNT.ToString().IndexOf(“.”) returns -1 if amount has no decimal point

AMOUNT.ToString().IndexOf(“.”) returns >0 value if amout has decimal point.


Open PDF File in Web Browser using C#

Using below code, no need to open file physically. We can also protect file to open from authorize access.


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

<html xmlns=””&gt;
<head runat=”server”>
<form id=”form1″ runat=”server”>
<h3 style=”color: #0000FF”>Open PDF files using ASP.NET</h3>
<asp:Button ID=”btnpdf” runat=”server” Text=”Click for open PDF file” Font-Bold=”True” OnClick=”btnpdf_Click” />


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;

public partial class OpenPDF : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)

protected void btnpdf_Click(object sender, EventArgs e)
string FilePath = Server.MapPath(“test.pdf”);
WebClient User = new WebClient();
Byte[] FileBuffer = User.DownloadData(FilePath);
if (FileBuffer != null)
Response.ContentType = “application/pdf”;
Response.AddHeader(“content-length”, FileBuffer.Length.ToString());

If this blog is helpful to you, Pls. click on like it.

How to use c# and vb code file in same project.

You may use both language in same application. Just create different folder like vb and csharp inside app_code then made changes inside web.cofing you may use. This way we tell compiler to compile code in vb or c# language.

Write below code in your web.config file under compilation element.

<compilation debug=”true” strict=”true” explicit=”true”>
<add directoryName=”VBCode” />
<add directoryName=”CSCode” />