I have a web form where i download a csv. i want to clear the form. but the form controls are not clearing.
protected void btndownload_Click(object sender, EventArgs e)
{
string inv = txtInvoiceNo.Text;
clear();
try
{
GetSelectedRecords(inv);
}
catch (Exception ex)
{
throw ex;
}
}
private void clear()
{
txtInvoiceNo.Text = "";
btndownload.Visible = false;
}
When i run without the GetSelectedRecords, its clearing.
code for csv download
private void GetCSV(DataTable dtsorted, string filename)
{
Response.Clear();
Response.ClearContent();
Response.ContentType = "application/text";
Response.BufferOutput = true;
Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
Response.Charset = "";
string sep = "";
for (int i = 0; i <= dtsorted.Columns.Count - 1; i++)
{
Response.Write(sep + dtsorted.Columns[i].ColumnName + ',');
}
Response.Write("\r\n");
for (int i = 0; i < dtsorted.Rows.Count; i++)
{
sep = "";
for (int j = 0; j <= dtsorted.Columns.Count - 1; j++)
{
Response.Write(sep + dtsorted.Rows[i].ItemArray[j].ToString() + ',');
}
Response.Write("\r\n");
}
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.SuppressContent = true;
HttpContext.Current.ApplicationInstance.CompleteRequest();
// Response.Clear();
//HttpContext.Current.Response.End();
}
Aucun commentaire:
Enregistrer un commentaire