|
Implement a Binding function and do it there.
C# has already designed away most of the tedium of C++.
|
|
|
|
|
this code not working can any help
Document document = new Document();
try
{
System.IO.MemoryStream msReport = new System.IO.MemoryStream();
PdfWriter writer = PdfWriter.GetInstance(document, msReport);
document.Open();
iTextSharp.text.Table datatable = new iTextSharp.text.Table(8);
datatable.Padding = 4;
datatable.Spacing = 0;
//datatable.setBorder(Rectangle.NO_BORDER);
float[] headerwidths = { 50, 50, 50, 50, 50, 40, 40, 45 };
datatable.Widths = headerwidths;
datatable.WidthPercentage = 100;
Cell cell = new Cell(new Phrase("Applicant Wise Report", FontFactory.GetFont(FontFactory.HELVETICA, 15 ,Font.BOLD)));
cell.HorizontalAlignment = Element.ALIGN_CENTER;
cell.Leading = 15;
cell.Colspan = 8;
cell.Border = Rectangle.NO_BORDER;
cell.BackgroundColor = new Color(0xC0, 0xC0, 0xC0);
datatable.AddCell(cell);
datatable.DefaultCellBorderWidth = 1;
datatable.DefaultHorizontalAlignment = 1;
datatable.DefaultRowspan = 1;
datatable.AddCell(new Phrase("Name", FontFactory.GetFont(FontFactory.TIMES, 11, Font.BOLD)));
datatable.AddCell(new Phrase("Address", FontFactory.GetFont(FontFactory.TIMES, 11, Font.BOLD)));
datatable.AddCell(new Phrase("State", FontFactory.GetFont(FontFactory.TIMES, 11, Font.BOLD)));
datatable.AddCell(new Phrase("City", FontFactory.GetFont(FontFactory.TIMES, 11, Font.BOLD)));
datatable.AddCell(new Phrase("Email ID", FontFactory.GetFont(FontFactory.TIMES, 11, Font.BOLD)));
datatable.AddCell(new Phrase("Exam Attended", FontFactory.GetFont(FontFactory.TIMES, 11, Font.BOLD)));
datatable.AddCell(new Phrase("Result Status", FontFactory.GetFont(FontFactory.TIMES, 11, Font.BOLD)));
datatable.AddCell(new Phrase("Exam Date", FontFactory.GetFont(FontFactory.TIMES, 11, Font.BOLD)));
datatable.DefaultCellBorderWidth = 1;
datatable.DefaultRowspan = 1;
if (Dt.Rows.Count > 0)
{
for (int i = 0; i <= Dt.Rows.Count - 1; i++)
{
datatable.DefaultHorizontalAlignment = Element.ALIGN_LEFT;
string name = Convert.ToString(Dt.Rows[i][0]);
datatable.AddCell(new Cell(new Phrase(name, FontFactory.GetFont(FontFactory.TIMES, 10, Font.NORMAL))),i+1,0);
string address = Convert.ToString(Dt.Rows[i][1]);
datatable.AddCell(new Cell(new Phrase(address, FontFactory.GetFont(FontFactory.TIMES, 10, Font.NORMAL))), i + 1, 1);
string state = Convert.ToString(Dt.Rows[i][2]);
datatable.AddCell(new Cell(new Phrase(state, FontFactory.GetFont(FontFactory.TIMES, 10, Font.NORMAL))), i + 1, 2);
string city = Convert.ToString(Dt.Rows[i][3]);
datatable.AddCell(new Cell(new Phrase(city, FontFactory.GetFont(FontFactory.TIMES, 10, Font.NORMAL))), i + 1, 3);
string mailid = Convert.ToString(Dt.Rows[i][4]);
datatable.AddCell(new Cell(new Phrase(mailid, FontFactory.GetFont(FontFactory.TIMES, 10, Font.NORMAL))), i + 1, 4);
string exam = Convert.ToString(Dt.Rows[i][5]);
datatable.AddCell(new Cell(new Phrase(exam, FontFactory.GetFont(FontFactory.TIMES, 10, Font.NORMAL))), i + 1, 5);
string result = Convert.ToString(Dt.Rows[i][6]);
datatable.AddCell(new Cell(new Phrase(result, FontFactory.GetFont(FontFactory.TIMES, 10, Font.NORMAL))), i + 1, 6);
string examdate = Convert.ToString(Dt.Rows[i][7]);
datatable.AddCell(new Cell(new Phrase(examdate, FontFactory.GetFont(FontFactory.TIMES, 10, Font.NORMAL))), i + 1, 7);
}
document.Add(datatable);
}
document.Close();
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=ApplicantWiseReport.pdf");
Response.ContentType = "application/pdf";
Response.BinaryWrite(msReport.ToArray());
Response.End();
|
|
|
|
|
|
if we want to take value in control through javascript
we will use
var ds = document.getElementById("dvMyDiv").value ;
if we are using master page means
var ds = document.getElementById("<%=dvMyDiv.ClientID %>").value ;
Why we are using ClientID while using master page ?
|
|
|
|
|
md_azy wrote: Why we are using ClientID while using master page ?
No idea, its your design, don't you know why you are doing it?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Whenever you are using MasterPages, the master page can contain dvMyDiv into it. So if you call it with this name only, it will be calling the masterpage dvMyDiv.
Generally after rendering the page, which is inside the masterpage, .NET prefix each control within the page with the masterpage placeholder name. Thus ambiguity could be removed by this.
Thus from javascript if you want to find this control, you need to call the valid object, means contentplaceholdername_dvMyDiv. Otherwise you could replace the javascript call through the server tags with the appropriate client id. Check your view source, you will get the idea of what the id of the control looks like in your page.
Abhishek Sur
|
|
|
|
|
md_azy wrote: Why we are using ClientID while using master page ?
Whenever a server control is inside a container control (like the Content control used by content pages), the id of the container is prepended to the id of the control to ensure that every id in the page is unique.
So, it's not only when you have a master page.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
Please, this question has been asked so many times. Just search here on CP for "save image to database" and you will find loads of answers.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
How a pdf file can be converted into swf using C# .net
|
|
|
|
|
I think you need some tool for doing this....
such as Print2Flash does this for you ...
Abhishek Sur
|
|
|
|
|
Hi, i have done one webpage contains a download button. When i click on that button, it picks file from local drive and has given option to open/save dialog box. But it giving with name of .aspx page
The code is as follows
downloadExcel.aspx
protected void Button3_Click(object sender, EventArgs e)
{
string filepath = "D:\\csvData.csv";
FileInfo file = new FileInfo(filepath);
if (file.Exists)
{
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/vnd.ms-excel";
Response.WriteFile(file.FullName);
Response.End();
}
}
G. Satish
|
|
|
|
|
Hi,
I have a need to use ContextMenuStrip control in aspx page. Plz do help if u have any idea.
Thanks for any help!
Lakshmi
|
|
|
|
|
Get it
Sathesh.
Blessed is the season which engages the whole world in a conspiracy of love.
|
|
|
|
|
Thank u Sathesh,
I want to use that ContextMenuStrip control in web application, for that what i need to do, i know how to use contextmenustrip in windows forms.
Lakshmi
|
|
|
|
|
hi
ASP Or ASP.NET if you meant ASP.NET here is my reply.
it's not possible to use contextmenustrip in webpage (by ASP.NET and ASP)
You can study about javascript.
Or you can look for a third-party server control that does it for you(like Ajax Toolkit Controls)
I think that you can also use WPF controls but I am not sure.
wish best.
MK4
|
|
|
|
|
Thank u for your response....
I'll try to do like you said!
Lakshmi
|
|
|
|
|
Hi,
I read in an MSDN article that we have to encode user input using HtmlEncode for security reasons. I used to do this many projects, but recently I encountered an issue. When the text is encoded it sometimes becomes huge that it exceeds the field length in database and db throws exception.
This is normal I suppose, is giving more length to db fields only solution for this?
Regards,
Blumen
“The thing for you is a burial permit. You have only to speak and I will see that you get it.”
|
|
|
|
|
Generally we do HTMLEncode when you need to disable javascripts to be running on the browser when it is shown in the web page.
I would suggest you to HTMLEncode before showing on the page rather than doing it while storing data into the database.
Why do you need to store the encoded string on the database.
Abhishek Sur
|
|
|
|
|
I encode data from Textboxes before saving them in database
“The thing for you is a burial permit. You have only to speak and I will see that you get it.”
|
|
|
|
|
Dont Encode before saving them in database. Rather, you should encode after you fetch from the database.
Abhishek Sur
|
|
|
|
|
hi,
i am doing a project which is just like google maps but my project is offline.so how will i do it.
coolsatty
|
|
|
|
|
What you mean by offline? Intranet application? Google map has some free and paid web services to get map data. Check Google documentation for more details.
|
|
|
|
|
Hi
I have to write some functions so i want to confirm whats better...
1. if i write one function with lot of functionalities
For exa.
Function Unit()
{
---- some code
-----
-------
---
----
.
.
.
}
2. if I break down this function in multiple functions and the call them inside the function and these function will be written in business layer.
For exa.
Function Unit()
{
---- some code
-----
Fun1(arg1,arg2)
---
Fun2(arg1,arg2)
.
.
.
}
Question 2 - is this a good practice (if not what are the drawbacks) or i must use directly Convert.ToInt16(oData).
****I am calling this at so many places
public static short ConvertToShort(object oData)
{
if (oData.ToString() == "")
{
return 0;
}
else
{
return Convert.ToInt16(oData);
}
}
Thanks
Dinesh Sharma
|
|
|
|
|
For 1st Q:
Regading performace both are almost same but for better managebility it always preferred to split in functions so that every function implement one feature.It's good practice.
for 2nd :
It'll be better if u use directly Convert.ToInt16(oData).but do use it in Try catch block cause if this function will not be able to convert it in int then it'll throw exception.
Cheers!!
Brij
|
|
|
|
|