I have an empty label when i try to display image from my computer to this label
this is the code :
Label1.Text += " " + "<img src='C:/Users/AA/Documents/Bureau/car/img/image3.jpg'>";
Include image in your project for example if you include in images folder. Following code will for you.
Label1.Text += "<img src='images/image3.jpg'></img>";
If you want to open it from same path try this
Label1.Text += " " + "<img src='file://C:/Users/AA/Documents/Bureau/car/img/image3.jpg'>";
Note: file://C:/Users/AA/Documents/Bureau/car/img/image3.jpg will be loaded in IE but not in Chrome or Firefox because loading files form direct path is considered security thread in Chrome and Firefox.
Considering all this i will suggest you to put images in Image and access them from there is simplest way to do it.
This is working example in asp .net c#.
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
Label1.Text = "<img alt='' src='images/download-img.jpg' />";
Sorry, I missed that it's ASP.net
You'll probably want to use Server.MapPath("~/image.jpg") stuff to be relative to deployment location. And close the tag.
Related
How Can (in a list with candidates) select one pdf/docx file and open it in a Iframe?
Here is an Image of how the list of candidates looks like:
Dont know exactly where do you want to show that iframe, but this code will help you:
Insert a Literal into your aspx:
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
And this is your C#
string pathFinal = "pdf/yourPDF.pdf"
string embed = "<object data=\"{0}\" type=\"application/pdf\" width=\"100%\" height=\"800px\">";
embed += "If you are unable to view file, you can download from here</object>";
Literal1.Text = string.Format(embed, ResolveUrl(pathFinal));
I am trying redirect to another page using below code
divIRSPayment.InnerHtml = divIRSPayment.InnerHtml
+ "Your Tax amount is $ "+lblBalance.Text
+ "<br />Click here to enter <a href='IRSEFWPayment.aspx'>IRS Payment Details</a>";
I have written above code in back-end. The amount is displaying successfully and text is also displaying successfully. But when i click on IRS Payment Details link, it is not redirecting to another page instead page is getting reloaded and displaying same page.
Probably you need to use absolute URL of the file rather than just the file name. Something like below using Page.ResolveUrl() method
".....<a href='" + Page.ResolveUrl("~/IRSEFWPayment.aspx") + "'>"
I have a simple web form in asp.net that has some validation on the form fields. I also have an image whose visibility is set to false. In my validation if statement I want code that will make that image visible if the validation has passed. Below is what I have but the image is not displaying. Thanks!
if (!Page.IsValid) return;
//Order is valid. Process it.
lblOrderDetails.Text = "<h1>Success!</h1>" +
"<b>Email: </b> " + tbEmail.Text + "<br />" +
"<b>Model: </b> " + dlModel.SelectedItem.Text + "<br />" +
"<b>Discounts: </b> ";
imgSnowboard.Visible = true;
<asp:Image Visible="false" runat="server" ImageUrl="~/SnowBoard.jpg" ID="imgSnowboard"/>
Two things, first unrelated to the question, I would start using string.Format as opposed to concatenating like that. It's just cleaner, and easier to manage. Ex.
lblOrderDetails.Text = string.Format("<h1>Success!</h1>
+ "<b>Email: </b>{0}<br />"
+ "<b>Model: </b>{1}<br />"
+ "<b>Discounts: </b> ", tbEmail.Text, dlModel.SelectedItem.Text);
Instead of the mess of + signs, this simplifies it a little more.
As to your question, I would say remove the Visible="false" property from the declaration, and instead, call out the image on PageLoad and set the visible property to false server side. Visible"false" can be kind of funky when you have a control declared with it. It almost acts like it doesn't create the control, and the C# has trouble accessing it, so it may be trying to show that image, but it literally cannot find it.
Hope this helps!
I'm trying to display a local PDF file in a WebBrowser-Control. I didn't want to use the Adobe-Libraries, because they don't support 64-bit. Now I already have the code to display a PDF, but only if it is not on the local HDD. When I right-clicked on the WebBrowser-Control and displayed the SourceCode of the HTML, I saved it as an HTML-File to check, if the HTML-Code is correctly working. Well, it works.
My window only consists of a maximized WebControl. I think the problem are the Security Settings of the local Internet Explorer. I read that a custom IInternetSecurityManager could solve the problem, but I don't know how to implement it... :/
I'm using C# with .NET Framework 4.0
Here is my code:
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
string url = "C:/test.pdf";
string html = "<!-- saved from url=(0014)about:internet -->\n<html>\n<body>\n<embed src=\"" + url + "\" width=\"100%\" height=\"100%\"/>\n</body>\n</html>";
webBrowser.NavigateToString(html); // System.Windows.Controls.WebBrowser
}
I the "saved from URL" part does only work if I directly open the HTML-Code in IE, so please tell me what to do, to get this code work... Maybe you have a better solution for my problem. Thanks for your help!
Regards,
Chris
Just use
webBrowser.Navigate("file:///" + url);
I have absolutely no idea on how to upload multiple files in asp.net using c#,with single upload button.Its not known in advance ,how many files are there.
Can somebody provide me the code in c#??I would be grateful.
Thanks in advance!!
Multiple uploads are not possible using a single upload control (you'll have to upload one file, then repeat the whole process again after the first file has been uploaded).
You can use an IFrame & some JS to rig up one such control which will allow you to upload multiple files at once (But then also, only one file will be posted to the server at a time, and its for the better, for the server).
Or you can use some third party controls created using Java technology (Applets) or in Flash.
This is an example using multiple textboxes and browse buttons to collect the paths of up to 5 files and then uploads them at once.
DotNetJunkies File Upload Tutorial
This one from MSDN uses the File Field Control to accomplish the same thing.
There is a lot of code in both of those articles that should get you well on your way.
You can create one upload input and have a button to add more dynamically using Javascript. When you click the save button, the files will all be in Request.Files.
<script type="text/javascript">
var uploadCount = 2;
function AddUpload()
{
var uploads = document.getElementById("uploads");
var id = "upload" + uploadCount;
uploads.innerHTML += ("<input type='file' id='" + id + "' name='" + id + "' />");
}
</script>
Add Upload
<div id="uploads">
<asp:FileUpload runat="server" ID="upload1" />
</div>
<asp:Button runat="server" ID="btnSave" Text="Save" />