Using AJAX 4 (latest version) I have been working with the html editor extender trying to upload images with text, I have got the Image to upload however it appears blank and when looking at the source, the source of the image is also blank (image below) how do I resolve this upload my selected image?
Include in HtmlEditorExtender an event handler for the ImageUploadComplete event.
<ajaxToolkit:HtmlEditorExtender
OnImageUploadComplete="MyHtmlEditorExtender_ImageUploadComplete"
...
Within the ImageUploadComplete event handler, you need to do two things:
1) Save the uploaded image
2) Provide the URL to the saved image so the image can be displayed within the HtmlEditorExtender
protected void MyHtmlEditorExtender_ImageUploadComplete(
object sender, AjaxFileUploadEventArgs e)
{
// Generate file path
string filePath = "~/Images/" + e.FileName;
// Save uploaded file to the file system
var ajaxFileUpload = (AjaxFileUpload)sender;
ajaxFileUpload.SaveAs(MapPath(filePath));
// Update client with saved image path
e.PostedUrl = Page.ResolveUrl(filePath);
}
Make sure you checked
http://www.asp.net/AjaxLibrary/AjaxControlToolkitSampleSite/HTMLEditorExtender/HTMLEditorExtender.aspx and
http://stephenwalther.com/archive/2012/05/01/ajax-control-toolkit-may-2012-release
Related
I have a UWP application where i have one folder which has multiple image files and HTML page which renders all images. This images are downloaded based on the listview item selections. I am using WebView control to render HTML page in my app.
I am able to display the HTML page loads correctly along with all JS and images, but the problem is that it shows the same images even though the images in the folder changed.
Here is how i am loading html page
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
if (e.Parameter != null)
{
webView360.Navigate(new Uri("ms-appx-web:///local/Image360Viewer/index.html"));
}
}
For example, Load only simple HTML with "Hello" in body then change to "Hello World" from text editor when application is still running then navigate to your view again, it should show "Hello World" but it will still show "Hello" which was the version when application started.
Edit: I have HTML and image in project folder structure.
Where're the images and HTML file? If these files are in app local folder. You need to use the Uri like this: "ms-appdata:///local/Image360Viewer/index.html"
The ms-appx-web URI scheme refers to a file that comes from your app's package, not app local folder.
Please read URI schemes for more information.
my web page is uploading images to server folder which is 'd:\upresim'
I adding images with that code:
protected void Button2_Click(object sender, EventArgs e)
{
FileUpload1.SaveAs(Server.MapPath("~/image/a.png"));
Image1.ImageUrl = "~/image/a.png";
}
I have a selected image, that I receive from FileUpload that I have added from the selected image to server upresim into folder.
Afterwords I need to show the added image on Image1, but it show nothing what can I do?
You have to upload images under your web app folder, for that folder your app has to have rigths to write to filesystem, and then set relative url to Image control ImageUrl. You should also check if upload has a file, and preferably use file name from uploaded file.
For example, let's say that you have folder upresim in your web site root folder, then use this code :
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath("/upresim/") + FileUpload1.FileName);
Image1.ImageUrl = "/upresim/" + FileUpload1.FileName;
}
my question is that how can i immediately display the server-side uploaded image [image being uploaded at a button click] ?
upload done using fileupload control.
image retrieval expected using image control.
below is the part of my code.
protected void Button1_Click(object sender, EventArgs e)
{
if(FileUpload1.HasFile)
FileUpload1.SaveAs(Server.MapPath("uploaded images/"+FileUpload1.FileName));
}
this code successfully uploads the image to "uploaded images" folder in the server.
but i failed to retrieve it to display as soon as it is uploaded.
below is what i tried, which never gave any programming error, though it never gave the
result too!
Image1.ImageUrl = (System.IO.Path.GetFileName(FileUpload1.FileName)).ToString();
help expected.
regards.
You really shouldn't assign local pathname as source for uploaded image.
Try something like
Image1.ImageUrl = "uploaded images/"+FileUpload1.FileName;
string imgPath = this.ResolveUrl("~/uploaded images/" + FileUpload1.FileName");
Image1.ImageUrl = imgPath;
Here's a full discussion of ASP.NET and image path issues.
I have one c# control and I am creating an image at runtime. The problem here is how do i open the file dialog when a user creates a submit button.
I have tried content-disposition but it is not working :(
Here is the scenario:
- I have one aspx file in that i have one ascx control file.
In that control file's cs file i am doing some rendering and creating one image unique to that user only. After creating that image i want to display it and download it
I have one button 'download' declared in control's html file and specified one method in the onclick event of that button
The function specified in onclick is written in cs file of that control. it is as follows:
public void DownloadPNG(object sender, EventArgs e)
{
Response.Clear();
Response.ContentType = "text/png";
Response.AddHeader("content-disposition", "attachment; filename=hello.png");
Response.Write("...");
Response.End();
}
Am I doing right?. Will this call this function? Is this function right?
Try using Response.WriteFile or Response.TransmitFile or even Response.BinaryWrite.
You've really given no information to figure out what you are doing.
However, if you want to make a content download as a file from an ASP.NET web page, here's an article I wrote that shows how to do just that.
I'm using a fileupload control to upload images. The upload is working but I would like to know how to display the uploaded image. For example,
user uploads file, (already done);
the image is displayed in the page.
Add an image control in your aspx page, and in the upload button event , add the URL of the image to the Image Control.
You can set the Image control visibility with false in the beginning and in the PostPack set it back to true to view your image.