Kentico 7 - Display an image from media library in web part - c#

I have created a custom web part for Kentico that needs to allow the content manager to select an image from the media library that will be set as a background image in a div. The form control I am using is Media Selection. Does anyone know how I can write the aspx and c# code to display the selected image? I feel like this should be an easy answer but I am coming up short. Any help would be great!

You can use MediaFileInfoProvider.GetMediaFileAbsoluteUrl() or MediaFileInfoProvider.GetMediaFileUrl() to get absolute or relative URL of the desired image and use it in aspx markup or codebehind. If you want to get "nice" URL, use example described here.

Related

Write values to text boxes on web page with CefSharp

I integrated CefSharp into my project. I was able to work out some points. However, I couldn't figure out how to check Inputboxes for example on a given site. So how can I write data into that InputBox. I request your help in this matter.
Thanks in advance.
You won't be able to modify the content of your web page running inside CefSharp from the C# code directly. What you can do however is to pass javascript code that will run on the page and will change content.
For example, something similar to this:
var browser = new ChromiumWebBrowser("https://www.example.com");
await browser.ExecuteScriptAsync("document.getElementById('myTextBoxId').value='the value'");

Dynamic images in ASP.NET Web application

Currently i'm investigating the possibilities to show dynamic images in our ASP.NET webforms application.
For example. we want to show the end user a 7 segment display on a web page, but before showing it, we need to change some things in this image, according to some settings in the databse, for example changing colors or set visibility of the segments, change background colors of elements etc.
Since our end users do not have the ablity to install browser plugins like Flash or Silverlight, it has to be something that is native supported by all recent browsers (maybe something like HTML5 or SVG?).
The main images should be created in design-time with some sort of WYSIWYG editor, like Illustrator or Blend or something. In run-time, we need to manipulate the image from C# (if serverside), or maybe even javascript (if clientside).
The main question is, are there eny techniques you would recommend, or are there any existing frameworks or libraries to accomplish this? Can this be easily done with SVG or HTML5 (canvas?)
I hope anyone can point me in the right direction, or provide some tips or maybe a good tutorial...
When I had to do something like this I used a new HTTP Handler. There in ProcesRequest you can load the image in a Bitmap object and modify it in-memory. After you are done you can write the image to the response.
//load the main image
var bmp = new Bitmap(200, 200);
//draw here
bmp.Save(context.Response.OutputStream, ImageFormat.Png);
context.Response.ContentType = "image/png";
context.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
context.Response.Cache.SetNoStore();
After having a handler like this you can add to the HTML. Make sure the response is not cached so the images are really dynamic.
Storing and editing the main image is a different question.

Multipage webforms in ASP.NET with the same url address

I making app when you can upload generally some files. So in upload action I wanna have 3 steps for uploading certain file. But If i will code it on 3 sites it wont be the same url. I just want to change content of eg. first page in first step and then if user add correct information I wanna change in that url content of that page. Can you helpme ? some ideas or example of code.
Alexander Dračka
You can use panel for the same.
Put your 3 codes in 3 panel and As per your requirement you can show and hide the panel.
What about Wizard control? it has several views and you can navigate each of them

To save webpage as image

I have to save webpage as image by passing page URL,i have found one solution on this thread Convert webpage to image from ASP.NET[^] but it doesn't give me proper image(e.g. tried URL http://www.bugmuncher.com/).
Also tried HTML to Image in C#[^] but not able to deal with IViewObject interface ,basically not able to add reference to get this interface.
I have to do something like http://www.usersnap.com does.I made it work on FF,Chrome and IE9 by using canvas element which is unfortunately not supported by IE8.
Can i get proper working solution for my need???
i think you mean taking a screenshot.
Here you are a link about it.
Capture screenshot of active window?
But here i found on the site that just you want. Please check it.
Convert webpage to image from ASP.NET
The webpage can be saved as image by 2 methods.
1. Press ctrl+p
2. Select "Send to onenote" in print prompt window.
3. Press ok.
Now the image can be saved from the microsoft office -> microsoft onenotebook and rightclick on your content. save as the image file.
Second method is by using snapshot via snipping tool.

How can I upload files asynchronously on ASP.NET?

I've been looking for a way to achieve this behavior and I found this sample project.
The trick in this project is that it changes the form target to an iframe created on the fly.
So far so good, I can get the byte[] on the server-side. But I need to change an image preview after the file is uploaded.
How can I get the iframe to update the main page? Would I have to save it on a file on the disk, make a javascript callback to change the image url? Is there another way to do this? What's recommended?
This control suggested by vorrtex actually causes a full page postback, am I missing something or is it the correct behavior?
I recommend you to use AsyncFileUploader and UpdatePanel. You have to save file on the disk but you can use C# for changing imageUrl.
Add a <script> block to the page that gets loaded in the <iframe> that interacts with the parent page and updates whatever you need to.
You can use the project mentioned below to preview the image before uploading. Working sample is also attached.
http://www.dotnetspider.com/resources/40858-Preview-Image-before-uploading-using.aspx
This uses AjaxControlToolKit's AsyncFileUploadControl and HTTPHandler to upload the image.

Categories

Resources