I'm working on dynamic datasite LINQ SQL admin panel where tables are displayed to edit, insert or delete. In a table , Image Column it shows the url of image. I want to display the image instead of URL. and when edit there should be a file upload button
and file should be saved in folder of website. Type for Image= navarchar MAX
You should share the codes so that we know how you implement this dynamic data in webforms.
Regarding how to display the image instead of URL, you could directly assign the url to the image control or convert the image to base64 format and assign the value to the image control.
If the control is of type dynamic, you might need to find dynamic control in the project and modify it as an image control in code behind.
Convert image to base64:
using (Image image = Image.FromFile(imagePath))
{
using (MemoryStream m = new MemoryStream())
{
image.Save(m, image.RawFormat);
byte[] imageBytes = m.ToArray();
// Convert byte[] to Base64 String
string base64String = Convert.ToBase64String(imageBytes);
// Assign the base64 string to the Image control
Image1.ImageUrl = "data:image/png;base64," + base64String;
}
}
Hope helps.
Best regards,
Sean
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
None
0 Points
1 Post
How to display and upload image in dynamic datasite asp.net webform
Feb 23, 2021 12:11 PM|salmanm22|LINK
I'm working on dynamic datasite LINQ SQL admin panel where tables are displayed to edit, insert or delete. In a table , Image Column it shows the url of image. I want to display the image instead of URL. and when edit there should be a file upload button and file should be saved in folder of website. Type for Image= navarchar MAX
All-Star
53001 Points
23593 Posts
Re: How to display and upload image in dynamic datasite asp.net webform
Feb 23, 2021 12:19 PM|mgebhard|LINK
Use the image tag to display an image.
https://www.w3schools.com/tags/tag_img.asp
File upload is covered in the official docs for the unknown framework you are working in.
https://docs.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-5.0
If you need further assistance, share your code. Explain the expected results and the actual results.
Contributor
2840 Points
840 Posts
Re: How to display and upload image in dynamic datasite asp.net webform
Feb 24, 2021 03:18 AM|Sean Fang|LINK
Hi salmanm22,
You should share the codes so that we know how you implement this dynamic data in webforms.
Regarding how to display the image instead of URL, you could directly assign the url to the image control or convert the image to base64 format and assign the value to the image control.
If the control is of type dynamic, you might need to find dynamic control in the project and modify it as an image control in code behind.
Convert image to base64:
Hope helps.
Best regards,
Sean