Translate This Blog

Problem :A gridview has a calendar extender for a textbox
when i try to send the gridview via email the following error appers





Solution

Before export or email gridview disable AjaxExtender control

 protected void Export_Click(object sender, EventArgs e)
    {
        DisableAJAXExtenders(this);
        ExportControl(this, DocumentType.Word, "ExportWord");
    }


    private void DisableAJAXExtenders(Control parent)
    {
        for (int i = 0; i < parent.Controls.Count; i++)
        {
            if (parent.Controls[i].GetType().ToString().IndexOf("Extender") != -1 && parent.Controls[i].ID != null)
            {
                parent.Controls.RemoveAt(i);
                parent.Controls[i].Dispose();
            }
            if (parent.Controls[i].Controls.Count > 0)
            {
                DisableAJAXExtenders(parent.Controls[i]);
            }
        }
    }

Previous
Next Post »
Thanks for your comment