I have an Web-application in which I capture Image using EdgeCamShots Sample Application
Saving Silverlight 4 Webcam
how can I use this capture image to be used in Next Page without saving Image.
A view model object reference (created from the application's MainPage) would be an object that both pages would have access to. Pass a reference to the pages on navigation changed event. That view model might make a good container for the stream and would give both pages access to the stream.
You can simply pass the stream (mentioned in the code example on the link you provided) to the next page using REST (adding the variable in the URL e.g. http://mysite/page2.aspx?stream=dstStream).
From there on, you can use the variable to show your picture.
Related
I am currently trying to create a custom server control in asp.net c# and am using VS2010.
I am trying to create a custom server control that can load images straight into a separate web project. E.g. Custom Server Control and a separate web project where I can drag and drop my control onto it with minimal installation and config. The point being it can be re used anywhere on other web projects.
I have created a basic custom control, but I need to be able to load images directly through the custom server control and display them in my separate web project. The images will be coming from a static location for the time being.
So basically I have an image, I want to load and pass that image into the control and then display it on a webpage where the custom control is placed. I have investigated image handlers, and having separate generic handlers but am not having any luck.
Image location --> Custom Control --> Web page displaying image that has been passed into custom control.
Anyone have any idea how to do this, or go about this?
UPDATE:
I am sorry I was not clear enough first time round.
I have two projects, one custom control project, and one asp.net website project. The first project (Custom Control) takes a byte stream from a webservice and converts it to an Image object. At this point I want the control to add that image to a webpage in the website. The custom control is then registered with the asp.net website and the controls I have added are rendered to the page. However I want to render the image I have recovered from the buffer, then converted to a file locally onto the web page.
I have no problem getting the image from the bytestream, and storing the image in a directory. The issue I am having is that I want the image to be rendered on the webpage, without having the image stored in the web project at first. I have thought about storing the image in a web directory so when I run the project I can set an image url to localhost/images/myimagefrombystream.jpg but am unsure whether this is the correct approach.
Any ideas?
We have a server controls library that contains some images that are reused across a number of other web projects.
The approach we took was to mark the each images build action as Embedded Resource. Then in the AssemblyInfo file we have lines like the following:
[assembly: WebResource("AssemblyName.SubDirectory.ImageName.png", "image/png")]
Where AssemblyName is the actual project name, the SubDirectory is the directory in the project the image(s) are located in, etc.
This project also emits CSS files; which are also Embedded Resources. The CSS files refer to these images using:
.someImage {
height: 85px;
background-image: url(<%=WebResource("AssemblyName.SubDirectory.Image.png") %>);
background-repeat: repeat-x;
margin: 0px;
padding: 0px;
}
In the class code, we'll refer to those css files like:
HtmlLink cssLink = new HtmlLink();
cssLink.Href = Page.ClientScript.GetWebResourceUrl(this.GetType(), "AssemblyName.css.SomeCssFile.css");
cssLink.Attributes.Add("rel", "stylesheet");
cssLink.Attributes.Add("type", "text/css");
We could just as easily refer to the images directly using something like the above.
At this point the assembly is 100% portable. All of the CSS files and required images are embedded into it so you don't have to worry if the calling application has those same images at all.
Incidentally, this is how a number of control vendors do things; at least the better ones.
I don't know why you're complicating. Simply, add ImageUrl property (not public field) to your custom control, expect the client-code of your control to set it, and if not null, in CreateChildControls add an Image control to the control tree. Alternatively, add the image to control-tree always, but make it visible/invisible from within the setter of that property (or elsewhere you see fit). I didn't understand half of what you said related to your envisioned solution, to be honest - so, I hope I didn't miss the topic here :)
I'm not sure I understood the question, but let me try anyway.
As far as I understood you have two projects, in one you want to upload an image to a certain location, in the other one you want to show that image.
I would simply have a file upload control in the 1st application, and use it to upload the image to the desired location.
In the other application you can use a generic handler. The handler can get the image file name from the 1st application using query string parameters, then it will locate the image on disk and return a response with a proper header, for example:
response.ContentType = "image/jpeg";
response.OutputStream.Write(image, 0, (int)request.InputStream.Length);
response.Flush();
response.End();
I assume that you have created this custom control in a class library. of the image source is static (some fixed base url) and just that image name changes you can expose a ImageUrl property (string) and render a tag based on the attributes (all can be default) with the custom ImageUrl as the src attribute of the tag.
Hope that helps!
Ok, I have an ActiveX web browser control on an Access form.
I am loading a url into this control using the following code:
Dim webMain As Object
Set webMain = Me.WebBrowser2.Object
webMain.Navigate "http://stackoverflow.com"
However, this page has multiple DIV's and I only want to show one.
Thanks
John
From your comment
I am only interested in one div in my form, as the other two are
menu's which they don't need to use or see. They just need to fill in
the form located within the main div and hit submit.
Well why bother with displaying HTML to them at all. Just collect the data on your Access form with Unbounded controls and POST the HTTP form yourself using MSXML2.ServerXMLHTTP or WinHttp.WinHttpRequest.5.1
For a sample see How can I send an HTTP POST request to a server from Excel using VBA?
We have a win application that shows a web form in a web browser.
In order to get data from this web form we are using a hidden text box and get its text using HtmlDocument object of web browser control.
I want to make an abstraction of this web form that has this text box element so that other forms can use this abstraction.
I made a web control and put the text box on it.I thought that if I put this control on my page it would have the text box.When i ran my application I noticed that the text box had been rendered but had its control name in its name (WebControl$TextBoxName) and its id(WebControl_TextBoxName) and the win app throw an exception since it couldn't find the element by its id(TextBoxName).
So here's my question:
How can I make an abstract web form/web control that has some elements on it and I can use it to make my final forms have these elements on them? (their names and ids should not be changed)
Thank you for your help
dotNet 4.0 supports static id's so they don't get mangled, read up on Client Id Mode
Alternatively, you could override the render of your control to output a standard html hidden form field with whatever ID you want, and then also add a custom property that will return the textbox that will hide the fact that it isn't an asp.net server control.
Though I've never used the browser control in WinForms, I think what you want to use is a Master Page. Assuming what you're rendering in the browser control is an ASPX page, create a Master Page with the hidden text box that you want to grab your data from, and tell all of the pages you want to have that common control on to use your Master Page. When the page renders, the control id will then be "ctl00_TextBoxName". There is no way of getting around the ID concatenation, since unique IDs are needed and that's the only way to guarantee uniqueness with all the nested control abilities of ASP.NET. However, doing this will guarantee you always have that control named the same on every new form you create that inherits the Master Page. Hope that helps!
In summary (because who reads paragraphs?):
Create Master Page
Place your common control in the Master Page
Have your Form inherit the Master Page
You can read up on how Master Pages work in MSDN's Documentation.
On my Form Load event I am creating a bitmap using System.Drawing classes, and I want to display this image on my WebForm. How can I do that?
Thanks!
You can't create this bitmap directly in your webform. You will need to implement custom HttpHandler that will render this image separately.
Serving Dynamic Content with HTTP Handlers
HTTP Handlers for Images in ASP.NET
Use Custom HTTP Handlers in Your ASP.NET Applications
Instead of creating the image in the code behind for your page, what you should do is create a URL for the image that somehow describes or defines the image's content (perhaps along with session state or a cookie if you need to), and attach that URL to a regular <img> (or <asp:Image>) tag.
Then, when the browser requests that URL, your code determines the parameters from the query string or cookies or whatever, generates and sends the response, and returns it with the correct MIME type. That's usually best done from a Generic HttpHandler (*.ashx).
I found out how to generate an image in code-behind based on some input from a webform, great. now i want to put that image back onto the form after the postback. All the samples i found use the Response to send the image back out to the browser with a stream.
Is there anyway to specify that the image generated in the code behind, be the source of a image control (or placeholder or whatever)?
If there is a way of doing this is there way of doing it without saving the image to the disk?
thanks
The web browser has to be able to retrieve the image somehow. If you don't want to save it, then it will require sending it with a Response stream.
You can create an HTTP Handler (ashx) and based on query string parameters generate and return an image. This would allow you to specify the image objects "ImageUrl" property as "~/MyImageHandler.ashx?param1=value1"
The http://imageresizing.net library can dynamically process images, as well as generate them. Could you provide more detail about what you are trying to do?