|
Hi all,
So my big problem is this, i have a class that creates a PDF directly to a memorystream. Whit this i can download and show a file in browser without doiwnloding it, the main problem is how can i redirect the file to a div, to be showned there.
Thanks
|
|
|
|
|
As far as I know, you can't do that. However, you can put an iframe tag inside the div and link the iframe to the location of the pdf, or in your case the webpage that serves the memorystream. Make sure to set the content type to application/pdf in the response header. The browser will take it from there.
|
|
|
|
|
This is my code
ReportViewer rptvw1 = new ReportViewer();
rptvw1.ProcessingMode = ProcessingMode.Local;
rptvw1.LocalReport.ReportPath = p.Server.MapPath("~/GridReport.rdlc");
BL_Insurance.PrintDetail print = new BL_Insurance.PrintDetail();
DataTable ds = print.Print(Convert.ToInt32(p.Session["transactionid"]), Convert.ToString(p.Session["typeofplan"]), Convert.ToInt32(p.Session["UserID"]));
ReportDataSource datasource = new ReportDataSource("DataSet1", ds);
rptvw1.LocalReport.DataSources.Clear();
rptvw1.LocalReport.DataSources.Add(datasource);
ReportParameter[] param = new ReportParameter[4];
param[0] = new ReportParameter("Company", Convert.ToString(p.Session["insurancecompany"]));
param[1] = new ReportParameter("Policy", Convert.ToString(p.Session["policyname"]));
if (ds.Columns.Contains("Adult"))
{
param[2] = new ReportParameter("Adult", "True");
param[3] = new ReportParameter("Child", "True");
}
else
{
param[2] = new ReportParameter("Adult", "False");
param[3] = new ReportParameter("Child", "False");
}
rptvw1.LocalReport.SetParameters(param);
rptvw1.LocalReport.Refresh();
Warning[] warnings = null;
string[] streamIds = null;
string mimeType = string.Empty;
string encoding = string.Empty;
string extension = string.Empty;
filetype = "PDF";
fname = DateTime.Now.ToString("yyyyMMddHHmmssfff");
byte[] bytes = rptvw1.LocalReport.Render(filetype, null, out mimeType, out encoding, out extension, out streamIds, out warnings);
finally am getting this format as byte array.
I want to print this byte array without saving any format.
Please tell me how to print this byte array directly.
|
|
|
|
|
How multiply two values one from database and one from user and print in another textbox.
|
|
|
|
|
- Read the values
- Parse them to integers or floats
- Multiply them together
- Format the answer to a string
- Put the string into the textbox
BTW, in future please use the correct forum, and explain your problem in better detail.
|
|
|
|
|
Hi All,
I am trying to prebuild and application when I have put the xcopy commands as below, initially it threw error as the specified folder doesn't exist at the target location.
Is there any way to write some intelligent login for the precompile so that when the precompile is happening, if there is no specified directory in the target location, it will create one automatically, if there is it will over write all the directories and files automatically without prompting the user.
Please any kind of help or support is very helpful, any link or suggestion or example would help a lot.
thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Use the /E switch with xcopy. That will copy the directory structure, including empty directories.
xcopy C:\Source\*.* D:\Target\*.* /E
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
I have used the same thing, it successfully does precompile once but then the folder and files are not available already it fails, by throwing error the command xcopy exited with code 2. May be it is unable to replace the existing ones.
Can you please give me option for both situations when there is no folder available and when there is everything available but still replaces with without prompting any message on to the command prompt.
Can you please help me in this regard.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
You can look at all the options available with xcopy by opening a command prompt window and entering "xcopy /?"
But it sounds like your problem is not with xcopy. It sounds like your problem is with some other program that is launching xcopy, is this correct?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
I don't what is causing the problem, these DOS and Windows errors hard to debug. I have used my xcopy with all the below switches. With every switch it is giving me the same error.
Switches:
xcopy "$(SolutionDir)\Core\*.aspx" "$(ProjectDir)\Core\"
/c /y
/e /k /i /c
/c /d /e /h /i /k /q /r /s /x /y
And error is same for all the switches. Any help please any sort of help is appreciated.
Unable to cast object of type 'Microsoft.TeamFoundation.Build.Workflow.Activities.AgileTestPlatformSpec' to type 'Microsoft.TeamFoundation.Build.Workflow.Activities.TestAssemblySpec'.
Failed - CopyDirectory to Destination folder failed. Robocopy Error # 16
I am not at all using Robocopy in my application once I used it some time before but now I replaced it with xcopy and above switches. I am not understanding what is the problem. Is it caching up I don't know why is it giving Robocopy error.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
I'm sorry but I cannot work out what programs you are using.
That error that you show is not an xcopy error. That's an error from some other program that you haven't disclosed.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
hey guys
I want to create a search function that searches for files with in a folder that matches the text that a textbox holds , how do i got about this
my code below looks for all the files and put it in a gridview but dont know how to make it so that it looks for a match betwwen the textbox and the files within the folder and only displays those
DataTable Dt = new DataTable();
Dt.Columns.Add("File", typeof(string));
Dt.Columns.Add("Size", typeof(string));
Dt.Columns.Add("Dir", typeof(string));
foreach (string filename in Directory.GetFiles(@"C:\files"))
{
FileInfo fileinfo = new FileInfo(filename);
Dt.Rows.Add(fileinfo.Name, fileinfo.Length +"KB", fileinfo.FullName);
}
GridView1.DataSource = Dt;
GridView1.DataBind();
PLease help Thanks
|
|
|
|
|
I believe you can use wildcards with Directory.GetFiles() . So just take the text box content and use it in the call to GetFiles() .
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi I've an application with an admin section, for example a dropdown list is poopulated with cities but if the user was to delete some records through the UI, verify their actions in the dropdown and then decided they wanted to undo their change. What would be the best way to enable rollback functionality like this?
|
|
|
|
|
Set a boolean field [deleted] for each entity you want to rollback. Instead of actually deleting the records, you can just set deleted=true and then, if you want to rollback, set it to false again.
Of course you need to consider the deleted field in your select queries.
I will never again mention that Dalek Dave was the poster of the One Millionth Lounge Post, nor that it was complete drivel.
How to ask a question
|
|
|
|
|
Hi All,
I have a Web Application called FDP which is in .Net 2.0 and there are other 4 applications which are in classic asp. Now we are planning to convert all these 5 applications in to .Net 4.5. We need to use a common master page for all 5 of them I have already implemented and tested it with static data.
Now the other problem is we have some user controls in FDP we have to use on Master page eventually would be common for all 5 applications going forward. Now the problem is when I reference the ascx file in master page by using the Virtual Path, then as the master page is referenced in other applications as dll, this Virtual Path and ascx file is not available there. And the application is throwing error.
Is there any way to reference ascx file in master page as dll or accessing the ascx file of the master page dll in the other applications. And this ascx file has code to access some database and config values, which have to be coming from those other application.
Is it possible to implement this solution. Please give me some advice or any link which can support me. I am also doing my best for this implementation. Please any type of support if very helpful.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Could you please give more details?
- What is your first problem? You only described your situation, not what the problem is.
- As for the second, we need to know how you try to reference the user controls and which error is being thrown.
<%@ Register TagPrefix="pre" Namespace="nameofnamespace" Assembly="nameofthedllwithoutextension" %>
So it should include a prefix, these are the letters you'll use to use any control contained in the assembly(the dll)
the namespace is the namespace that contains the usercontrol
the assembly is the name of the dll file(most likely in your debug folder while testing) but without the dll extension added. No path should be required afaik.
|
|
|
|
|
The problem is we want to have only one common master file across the projects. For that I have solved it by using the master page dll concept as given here in this blog. () [^] But the problem is as I am accessing a dll of master page if I want to add a user control to it then its ascx file is not available when we reference its dll.
Then I came up with a solution to convert the user controls also into custom controls so that I can put them on the master page and access them.
Now for that I am getting the following error.
Error 86 Cannot use a leading .. to exit above the top directory. ASPNETCOMPILER 0 0 Core
And I have another doubt, that if I have any images and configuration values used in a customer control code, how should I deal with them? Can you please guide me or help me or send a link to me so that I can implement it in best possible way.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
I'm lacking a lot of details but here is my educated guess:
You're trying to reference the dll in your webpage by using a relative path that goes above your web application root.
You should add the dll as a reference to your project, then refer to the name of the dll. Do not include the path or the extension.
<%@ Register TagPrefix="ctl" Namespace="CustomControlNamespace" Assembly="CustomControl" %>
The attribute Assembly refers to the name of the dll.
As for your doubts about configuration and images, really gonna need to see some of your code to help you out there.
|
|
|
|
|
I have put the image file path in appSettings of the Web config of web application which is consuming the Custom Control as below
<add key="Images" value="~/Images"/> Then I have placed code piece in the code behind of the custom control
ConfigurationSettings.AppSettings["Images"].ToString<pre>();
If we do this we is it going to work?
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
That code will work but that way of retrieving settings from Web.config is outdated/deprecated and may not work in future versions of .net.
This link is the recommended way of doing it, according to Microsoft:
Microsoft Recommendation
|
|
|
|
|
Hi,
Yes that is absolutely correct, we are in process of converting this 2.0 application into 4.5, so the one that I have put was 2.0 code, but your suggestion definitely helped me. Thank you very much.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
But I don't know why but the namespaces and classes from that assembly are not at all coming in the intellisense. When I put those names explicitly they were giving syntax errors.
Please help me in this regards.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
In code-behind pages, you link a prefix to the assembly, which is done in the code I posted in previous post. After that, you place a control on your webpage. It will have a prefix, then the name of your control, and only the name of that control. Giving the full name will indeed give syntax errors.
If you placed
<%@ Register TagPrefix="vg" NameSpace="coolstuff" Assembly="coolstuff" %> on top of your page, you should place
<vg:CoolControl id="testcontrol" runat="server">
in your page where you place your control(s).
If I'm misinterpreting your question, please provide more details.
|
|
|
|
|
I am using OpenXML to generate Excel doc how to I apply styles for specific cell?
Dim CellStyleFormats As New CellStyleFormats
With CellStyleFormats
.?????
End With
mergeCell.Append(CellStyleFormats)
mergeCells.Append(mergeCell)
|
|
|
|