TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Priyank Varshney
NA
16
5.5k
Object reference not set to an instance of an object. Error
Dec 14 2016 7:46 AM
Hello,
I am developing a project, in that project i want that, after submitting the data, user can generate pdf of that data. I enclosed the data into a panel to generate a pdf. On Generating pdf i am getting an error, and it is
Object reference not set to an instance of an object.
my onbuttonclick function is like:
protected void btnPdf_Click(object sender, EventArgs e)
{
btnUpload.Visible = false;
FileUpload1.Visible = false;
string attachment = "attachment; filename=" + "abc" + ".pdf";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/pdf";
StringWriter s_tw = new StringWriter();
HtmlTextWriter h_textw = new HtmlTextWriter(s_tw);
h_textw.AddStyleAttribute("font-size", "7pt");
h_textw.AddStyleAttribute("color", "Black");
Panel1.RenderControl(h_textw);//Name of the Panel
Document doc = new Document();
doc = new Document(PageSize.A4, 5, 5, 15, 5);
//FontFactory.GetFont("Verdana", 80, iTextSharp.text.Color.RED);
//FontFactory.GetFont("Verdana", 80, iTextSharp.text.BaseColor.RED);
PdfWriter.GetInstance(doc, Response.OutputStream);
doc.Open();
StringReader s_tr = new StringReader(s_tw.ToString());
HTMLWorker html_worker = new HTMLWorker(doc);
html_worker.Parse(s_tr);
doc.Close();
Response.Write(doc);
}
Please help me to resolve this error..
Thank You...
Reply
Answers (
2
)
how to connect ms sql database with web api
ASP.net gridview persist radio button selection.