Answered by:
A single control for WEB and Desktop application using C#

Question
-
Hi Friends,
Is it possible to create rich UI controls like grid, textbox, button with events such way, so it can be used for both WEB and Desktop application using C# ?
Wednesday, November 14, 2012 1:48 PM
Answers
-
Not really. Two entirely different technologies. The closest you can come is an ActiveX control but even then the control has to be written to be script safe. This is ignoring the fact that ActiveX controls are generally not allowed to run on web pages anymore.
You can write an app that can be run from either the web or desktop. Silverlight is the best example of this technology. ClickOnce apps go the other direction in that they are desktop apps that can be launched from the web. Finally Metro apps (Windows 8+) will allow you to write HTML5 apps that run on the desktop. You should review these technologies to see if they serve your needs.
Michael Taylor - 11/14/2012
http://msmvps.com/blogs/p3net
Wednesday, November 14, 2012 2:54 PM
All replies
-
Not really. Two entirely different technologies. The closest you can come is an ActiveX control but even then the control has to be written to be script safe. This is ignoring the fact that ActiveX controls are generally not allowed to run on web pages anymore.
You can write an app that can be run from either the web or desktop. Silverlight is the best example of this technology. ClickOnce apps go the other direction in that they are desktop apps that can be launched from the web. Finally Metro apps (Windows 8+) will allow you to write HTML5 apps that run on the desktop. You should review these technologies to see if they serve your needs.
Michael Taylor - 11/14/2012
http://msmvps.com/blogs/p3net
Wednesday, November 14, 2012 2:54 PM -
Thanks CoolDadTx,
So, as I understood the optional are,
1. Silverlight : A single application can run both in browser as web and in desktop also. Right ?
2. ClickOnce : Does it mean Xbap ?
3. HTML 5 : For Windows 8 and onwards..
Finally, my application is big business application. Here one is service part and another is client one.
The service part will be in WCF, but here the main key is client part which should be run in WEB and Desktop together. And we do not want to write code separately for both web client and desktop client.
So, I am not sure where this kind of big business client application can be feasible to do in Silverlight Or Xbap Or Html5.
Thursday, November 15, 2012 6:04 AM -
I think that the Prism project from Microsoft Patterns and Practices has guidance on how to create a single codebase which can compile to either Silverlight or WPF giving you both a web and a desktop version.
http://compositewpf.codeplex.com/
Paul Linton
Thursday, November 15, 2012 6:34 AM -
1) SL is probably not the best option going forward but it would work.
2) ClickOnce is a normal Windows app (Winforms, WPF) that is deployed via a web URL and stored on a per-user basis on the local machine. You don't have permissions to do anything that impacts the whole machine (registry, shared files, etc) but for client apps it works pretty good.
In all honest you're not really going to be able to create a single app that runs on both the web and Windows environments. It probably doesn't even make sense to do so. I'd evaluate why you need to work in both environments and then come to a decision on which type of app you really need. If deployment is the biggest concern then a web app or ClickOnce app would fit the bill. If advanced functionality is needed then Windows is the only real choice. If some users need a filtered view while other users need a full-featured product then a Windows app with a (separate) limited web app is the best approach. If you must have a full featured app on the web and Windows then creating a single web app is sufficient. All Windows machines can access the web app so deployment isn't an issue.
You're going to end up having to replicate behavior but if you are breaking your app up properly then the UI(s) you build aren't that big of a deal. The business logic and data access will all be isolated to separate assemblies so swapping out the front end becomes just another project. A good example of this is Outlook. The Outlook client and the web interface are 2 completely different binaries but they share the same underlying object layer. The only difference is the UI project - one for Windows and one for web.
Michael Taylor - 11/15/2012
http://msmvps.com/blogs/p3net
Thursday, November 15, 2012 4:13 PM -
Actually, I want to save my cost to develop diffierent client (web and desktop). This application should work in disconnected mode, that's why we need desktop version too.
Friday, November 16, 2012 7:49 AM -
Thnx,
SL would not be good option for future. But I will try this option surely.
Friday, November 16, 2012 7:56 AM