when i click the download(link button) in grid view am showing a pop up box(to valide mobile number am sending OTP to mobile ,in pop up box i have Text box and button control ) ,
when i submit otp in pop up if he is a valid then start download document if not show error message
am getting error as
when i click download , pop up is showing and download also starting
but i want to verify user in pop up , when he submit valid otp then download should start
Hide Copy Code
<asp:GridView ID="GridView1" runat="server" HeaderStyle-BackColor="#cccccc" HeaderStyle-ForeColor="Black" RowStyle-BackColor="white" RowStyle-ForeColor="#003366" AlternatingRowStyle-BackColor="White" AlternatingRowStyle-ForeColor="#000" AutoGenerateColumns="false" Font-Bold="False"> <Columns> <asp:BoundField DataField="UserName" HeaderText="User Name" /> <asp:BoundField DataField="DocumentType" HeaderText="Document Type" /> <asp:BoundField DataField="FormType" HeaderText="Form Type" /> <asp:BoundField DataField="Description" HeaderText="Description" /> <asp:TemplateField ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:LinkButton ID="lnkDownload" runat="server" Text="Download" OnClick="DownloadFile" OnClientClick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block';" CommandArgument='<%# Eval("Id") %>'></asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
cs code
protected void DownloadFile(object sender, EventArgs e)
{
//if (txtOtp.Text == txtName.Text)
//{
int id = int.Parse((sender as LinkButton).CommandArgument);
byte[] bytes;
string DocumentType, FormType, fileName, Description, contentType;
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
cmd.CommandText = "select UserName,DocumentType,FormType,Name, Data, ContentType,Description from tblFiles ";
cmd.Parameters.AddWithValue("@Id", id);
cmd.Connection = con;
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
sdr.Read();
bytes = (byte[])sdr["Data"];
DocumentType = sdr["DocumentType"].ToString();
FormType = sdr["FormType"].ToString();
contentType = sdr["ContentType"].ToString();
fileName = sdr["Name"].ToString();
Description = sdr["Description"].ToString();
}
con.Close();
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = contentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
//}
//else
//{
// Response.Write("<script> alert('wrong otp.......')</script>");
//}
}when i click the download(link button) in grid view am showing a pop up box(to valide mobile number am sending OTP to mobile ,in pop up box i have Text box and button control ) ,
when i submit otp in pop up if he is a valid then start download document if not show error message
am getting error as
when i click download , pop up is showing and download also starting
but i want to verify user in pop up , when he submit valid otp then download should start
Hide Copy Code
<asp:GridView ID="GridView1" runat="server" HeaderStyle-BackColor="#cccccc" HeaderStyle-ForeColor="Black"
RowStyle-BackColor="white" RowStyle-ForeColor="#003366" AlternatingRowStyle-BackColor="White" AlternatingRowStyle-ForeColor="#000"
AutoGenerateColumns="false" Font-Bold="False">
<Columns>
<asp:BoundField DataField="UserName" HeaderText="User Name" />
<asp:BoundField DataField="DocumentType" HeaderText="Document Type" />
<asp:BoundField DataField="FormType" HeaderText="Form Type" />
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:LinkButton ID="lnkDownload" runat="server" Text="Download" OnClick="DownloadFile" OnClientClick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block';"
CommandArgument='<%# Eval("Id") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
cs code
protected void DownloadFile(object sender, EventArgs e)
{
//if (txtOtp.Text == txtName.Text)
//{
int id = int.Parse((sender as LinkButton).CommandArgument);
byte[] bytes;
string DocumentType, FormType, fileName, Description, contentType;
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
cmd.CommandText = "select UserName,DocumentType,FormType,Name, Data, ContentType,Description from tblFiles ";
cmd.Parameters.AddWithValue("@Id", id);
cmd.Connection = con;
con.Open();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
sdr.Read();
bytes = (byte[])sdr["Data"];
DocumentType = sdr["DocumentType"].ToString();
FormType = sdr["FormType"].ToString();
contentType = sdr["ContentType"].ToString();
fileName = sdr["Name"].ToString();
Description = sdr["Description"].ToString();
}
con.Close();
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = contentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.BinaryWrite(bytes);
Response.Flush();
Response.End();
//}
//else
//{
// Response.Write("<script> alert('wrong otp.......')</script>");
//}
}