How can I manage a WinForms .NET component from ASP.NET? - asp.net

I have a WinForms .NET component that can render and save JPG images. How can I make it work on my ASP.NET website each time a visitor requests a page?
Do I need write a web service?
Do I need to run a winforms app on the server and interact with it?
Do I need to host it on a separate ASP.NET page and query it to render and save new images?
Thanks.
EDIT: I am looking for a solution that doesn't need any control to be downloaded but simply a page refresh to display the new image.

Simple way to expose a .NET WinForm control as an ActiveX control in any HTML or aspx page
http://www.codeproject.com/KB/miscctrl/htmlwincontrol.aspx

Related

Same Component in both asp.net, asp.net MVC and Classic ASP

I have a big website/application coded in Classic ASP, ASP.NET and ASP.NET MVC.
I have a menu on top with a lot of HTML CSS JS, and some conifiguration (visible or not ...)
and lot of dynamic links.
So the problem is when i have to update the menu i have to update 3 files, one Include in Classic ASP, one ASCX user control in asp.net and one Partial view in asp.NET MVC
I hate code duplication, so is it possible to use only one component ?
I heared about Com but i have no idea where to start.
Thanks for help
Edit : I am thinking know to use a .net Object, that can generate a string containing all the html that i need and then put it in the views MVC and in the asp.net pages
But how to use it in Classic ASP?
There's nothing stopping you using a webapi controller to expose this functionality; the webapi controller would return json or xml menu structure to the client browser this in turn would be rendered using by injection of the json over into the browser DOM and styled using CSS.
Classic ASP and MVC ASP.NET would use the same javascript and css.
I'm also working in a legacy application that is very much similar to your case, how bad the life is :(
I'll go for XML/XSLT in your case.
I'll create an XML file that contains all the menu details and use XSLT to generate HTML from XML. I can easily use the XML and XSLT in all the three technologies. So every time you need a change you have to change either the XML or XSLT file.
You can even create a simple .NET component that uses the XML/XSLT approach which could be easily used in ASP.NET Web Forms, ASP.NET MVC (in custom view engine?) and in classic asp as well (you have to register).
Guess, you can make an action method in asp.net MVC to render the dynamic menu and do AJAX load from the javascript in every part of the site?
UPDATE:
You can make an HTTP GET request in classic ASP to the aforementioned ASP.NET MVC handler, and cache results if its not very dynamic. Anyway it should be pretty fast if its within the same server. I suppose, request will look like in this answer

Open Sharepoint Application Page inside ASP.Net web app

I have the unusual situation to solve... There is a application page that runs inside SharePoint 2010 with a form to upload some file to a Document Library.
The thing is that this application page needs to be showed on a modal inside my ASPX web app.
I got this running using simplemodal jquery plugin running inside a iframe.
My question is... how can I achieve this functionality considering security questions like a controlled access to this application page? My SharePoint site does not allow anonymous access so I need to figure out how to allow public access only on this page.
I would re-create the page in this asp.net application and then communicate with sharepoint using the client object model or perhaps another approach such a custom webservice (but client model should be ok). I would say that this is the only clean way to achieve your goal.

How to open a silverlight web application as light window?

I created simple Silverlight Application using the web site host of the VS2010 ( default ) feature.
Now, I want to make the Silverlight Application to be shown as light window in the front of the default web site.
How can i do it ?
You can go OoB.
If you just wanted to show a modal dialog, then use the ChildWindow or MessageBox.
I think you could also remove the website from your solution and the Silverlight project will still open in the browser.
I am not so sure about what you mean by "Light Window", but I am sure these links will help you a lot:
Integrating Silverlight with a Web Page
How to: Add Silverlight to a Web Page by Using HTML
Update
If you checkout the web-host project, you'll see, that there is a test page that actually hosts the Silverlight project.
You can modify this page and move the Silverlight content around wherever necessary, or you might even embed it in a master page and/or use an external ASP.NET UserControl that will be used to load/host the Silverlight object dynamically.

Create Thumbnail from url using asp.net 2.0

Can any one help me on how to create a thumbnail from a url.
when the user saves a link, i want to show the screenshot of the web page as a thumbnail
i am using asp.net 2.0
Thank You
If you need to do this yourself, you can use the Winforms WebBrowser control in an ASP.NET application, with a few caveats:
It needs to run in a single threaded apartment thread
It might not work on all pages, such as pages which require Javascript or Flash interaction
Here are a few links to some walkthroughs:
Build A Self-Caching ASP.NET Web Site Thumbnail Control
How To Get Web Site Thumbnail Image In ASP.NET
I'd look at using a webservice like thumbalizr or WebShotsPro.
alt text http://beta.thumbalizr.com/app/thumbs/?src=/thumbs/onl/source/78/78f5e5a94c19c2999b1dc6eec3a2f2bf.png&w=640&q=0&enc=

Sending asynchronous request on clicking a sharepoint web part button control

I am new to this whole sharepoint and aspx programming. I have developed a sharepoint web part that has a button control. The onclick event is mapped to a method in my web part code. When I click the button the whole page reloads and the web part is rendered again. Is there a way to prevent this reloading of the page? Is there a way to call the function method in the background? Something similar to AJAX.
Thanks,
Jagannath
You can use Ajax, it just requires some sharepoint configuration. Here are a few posts to get you started:
http://weblogs.asp.net/jan/archive/2007/02/26/using-the-ajax-control-toolkit-in-sharepoint.aspx
http://sharepoint.microsoft.com/blogs/mike/Lists/Posts/Post.aspx?ID=3
Ajax or SilverLight are your only two options for Async operations without a page refresh.
Once you know the tricks needed to get SharePoint and ASP.NET AJAX to work together it's not that difficult.
Here are the steps required:
Ensure the ASP.NET AJAX Extensions are installed on all the front-end web servers (this is not required if you are using .NET 3.5 as the Extensions are included in the Framework)
Update the Web.config file for the SharePoint Application to support ASP.NET AJAX
Ensure any page that is going to use AJAX has a ScriptManager
Use an UpdatePanel or a client-side service call to get updated data and re-render the Web Part
This blog post has some resources from a talk I did on the subject at TechEd Barcelona 2008. These resources should give you the information you need to get started.
http://msmvps.com/blogs/windsor/archive/2008/11/13/teched-emea-resources-and-demos-integrating-asp-net-ajax-with-sharepoint-2007.aspx

Resources