Dear Sir,
I want to display file, while click on view button.
<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeFile="vw.aspx.cs" Inherits="BGMS.vw" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<table border="2" cssclass="auto-style53" height="500px" width="1900px" cssclass="auto-style53" align="center">
<tr>
<td style="font-weight: bold; background-color: #003366; font-size: large;" colspan="2"><span style="color: #FFFFFF"><b><span class="auto-style5" style="font-size: large"><strong>Emp. Id:<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></strong></span></b></td>
<span class="auto-style9">
<td style="background-color: #003366; font-size: large;" colspan="2"><span style="color: #FFFFFF"><b><strong>Emp.Name:<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></strong></b></td>
<td style="background-color: #003366; font-size: large;" colspan="2"><span style="color: #FFFFFF"><b><strong>Designation:<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label></strong></b></td>
<td style="background-color: #003366; font-size: large; width: 148px;"><span style="color: #FFFFFF"><b><strong>Deptt.:<asp:Label ID="Label4" runat="server" Text="Label"></asp:Label></strong></b></span></td>
<td style="background-color: #003366; font-size: large; width: 148px; color: #FFFFFF;"><strong>BGMS ID :<asp:Label ID="Label5" runat="server" Text="Label"></asp:Label></strong></td>
<td style="background-color: #003366; font-size: large;"><span style="color: #FFFFFF"><strong>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" OnClick="LinkButton1_Click" CssClass="auto-style64" Style="color: #FFFF99">Back</asp:LinkButton></strong></td>
</tr>
</span><span class="auto-style5"><span class="auto-style9">
<tr>
<td style="background-color: #669999">
<span class="auto-style9"><strong>Agency Name :
</strong></span>
</span>
</strong>
</td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<asp:TextBox ID="TextBox1" runat="server" CssClass="auto-style9" Height="32px" Width="224px"></asp:TextBox>
</span></span>
</td>
<td style="background-color: #669999">
<span class="auto-style9"><strong>Type of BG :
</strong></span>
</td>
<td style="background-color: #669999">
<span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox2" runat="server" CssClass="auto-style9" Height="32px" Width="224px"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"><span class="auto-style9"><strong>NIT No
:</strong></span></td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox3" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"><span class="auto-style9"><strong>PO No:
</strong></span>
</td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox4" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"> </td>
</tr>
<tr>
<td style="background-color: #669999"><strong><span class="auto-style9">BG No:
</strong>
</span>
</td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox5" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"><span class="auto-style9"><strong>BG Issued Date:
</strong></span>
<script src="js/jquery-3.4.1.min.js"></script>
<script src="jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
<script>
$(document).ready(function () {
$('#TextBox6').datepicker({
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true,
yearRange: '1950:2050'
});
})
</script>
</td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox6" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"><span class="auto-style9"><strong>BG Expiring Date
:
</strong></span>
</td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox7" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"><span class="auto-style9"><strong>BG Issuing Bank
:
</strong></span>
</td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox8" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"> </td>
</tr>
<tr>
<td style="background-color: #669999"><span class="auto-style9"><strong>BG Received Media:</strong></span></td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<asp:TextBox ID="TextBox9" runat="server" CssClass="auto-style9"></asp:TextBox></strong>
</span></span>
</td>
<td style="background-color: #669999"><span class="auto-style9"><strong>1st Received by whom:</strong></span></td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox10" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"><span class="auto-style9"><strong>BG Handed Over to:</strong></span></td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox11" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"><span class="auto-style9"><strong>Action Pending: </strong></span>
</td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox12" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"></td>
<tr>
<td style="background-color: #669999"><span class="auto-style9"><strong>Scheduled Del Dt:</strong></span></td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox13" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"><span class="auto-style9"><strong>% Delivered:</strong></span></td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox14" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999"><span class="auto-style9"><strong>Date of Final Delivery:</strong></span></td>
<td style="background-color: #669999"><span class="auto-style5"><span class="auto-style9">
<strong>
<asp:TextBox ID="TextBox15" runat="server" CssClass="auto-style9"></asp:TextBox>
</strong>
</span></span>
</td>
<td style="background-color: #669999; font-weight: bold;" colspan="2"><strong>View File: </strong>
<asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">Click Here</asp:LinkButton></td>
<td style="background-color: #669999"><b></b></td>
</tr>
<tr>
<td style="background-color: #669999" colspan="2"> </td>
<td style="background-color: #669999" colspan="4">
<strong>
<span class="auto-style5"><span class="auto-style9">
<asp:Button ID="Button1" runat="server" Text="Save" Height="29px" Width="114px" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Cancel" Height="29px" Width="114px" OnClick="Button2_Click" />
</span></span></td>
<td style="background-color: #669999" colspan="2"> </td>
<td style="background-color: #669999" colspan="2"> </td>
</table>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder3" runat="server">
</asp:Content>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection.Emit;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace BGMS
{
public partial class vw : System.Web.UI.Page
{
int empno = 0;
protected void Page_Load(object sender, EventArgs e)
{
empno = Convert.ToInt32(Request.QueryString["Id"].ToString());
// Session["EMP_ID"] = empno;
String EMP_ID = Session["EMP_ID"].ToString();
Label1.Text = " " + EMP_ID + "";
String emp_nm = Session["EMP_NAME"].ToString();
Label2.Text = "" + emp_nm + " ";
String EMP_DSG = Session["DEPT_ID"].ToString();
Label4.Text = "" + EMP_DSG + " ";
String dept = Session["EMP_DSG"].ToString();
Label3.Text = "" + dept + " ";
if (!IsPostBack)
{
BindTextBoxvalues();
// BindGrid();
}
}
private void BindTextBoxvalues()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("select * from bgms where Id=" + empno, con);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
Label5.Text = dt.Rows[0][0].ToString();
TextBox1.Text = dt.Rows[0][2].ToString();
TextBox2.Text = dt.Rows[0][3].ToString();
TextBox3.Text = dt.Rows[0][4].ToString();
TextBox4.Text = dt.Rows[0][5].ToString();
TextBox5.Text = dt.Rows[0][6].ToString();
TextBox6.Text = dt.Rows[0][7].ToString();
TextBox7.Text = dt.Rows[0][8].ToString();
TextBox8.Text = dt.Rows[0][9].ToString();
TextBox9.Text = dt.Rows[0][10].ToString();
TextBox10.Text = dt.Rows[0][11].ToString();
TextBox11.Text = dt.Rows[0][12].ToString();
TextBox12.Text = dt.Rows[0][13].ToString();
TextBox13.Text = dt.Rows[0][14].ToString();
TextBox14.Text = dt.Rows[0][15].ToString();
TextBox15.Text = dt.Rows[0][16].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Redirect("main.aspx");
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
LinkButton lnkbtn = sender as LinkButton;
GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
string filePath = "~//img//" + Label5.Text;
Response.Write(String.Format("<script>window.open('{0}','_blank');</script>", "viewImage.aspx?fn=" + filePath));
}
}
}