I wrote a C# program that works good.
I want to execute that project, in a website, so the main form of my project will be in the web form.
I tried this code in the web application webform:
protected void Page_Load(object sender, EventArgs e)
{
Program.Form1 y = new Program.Form1();
y.ShowDialog();
}
and it works, but my program does not appear in the website, but in another window, and the website stays empty and in continuous linking trial condition.
How can I insert my program into the website window?
What you are calling a "C# Project" is a Windows Forms project. It it not compatible with ASP.NET. You cannot run it that way.
Read about ASP.net, its a tool to develop websites with C#. Programs and websites are 2 different things and you can't run your program in a website. For example, you can't run games in your browser because it is written differently.
Read about it, its very simple to use.
The code in your projects is using the same language (in your case, C#, but it could also be VB) but WinForm applications and Web applications are two different things. The make a long story short, the user interface of the first one will be Windows application installed on a machine while the second one will be displayed in a browser (and hosted on a web server). The bottom line is that those project type cannot be mixed.
However, if you want to reuse some of your code in a Web or a WinForm application, you should consider creating a library project. You'll be able to manage all the code that doesn't refer to specific UI from there and you'll be able to reference it from both of your projects.
Related
I have a quite small (so far) project which consists of
Core
GUI
TUI
The TUI (console application) is communicating with another console application in order to send and retrieve certain information.
The purpose of the GUI is to make it easier.
However, I am stuck on how would I make my TUI communicate with my GUI. So far, I know I can start my TUI from the GUI like this:
System.Diagnostics.Process.Start(#"cmd.exe", #"/k C:\project\TUI\bin\Debug\TUI.exe");
But now, I do not have any reference to the console application and I do not know to send information forth and back. I tried to search for the answer, but my search would only lead to how to start them in a normal way (not both, together, communicating).
So all in all, my question is: How to start a console application from windows forms project so those two to be able to communicate?
You can use the Input and Outut Streams of the Process.
Read this :
https://msdn.microsoft.com/de-de/library/system.diagnostics.process.standardinput(v=vs.110).aspx
I created a application let say "Mydesktopapp"(which is mix of C# and c++ deliverables and few XML's file).
'Mydesktopapp' can be run by clicking a batch file. Hence once user click on batch file, application gets executed and does it functionality on a desktop system.
Now i want to provide this application to the user through a webpage(so that everybody don't need to explicitly copy Mydesktopapp and then run it, instead user should just open a webpage from anywhere...and should click a button on webpage and application should get downloaded and run.
To achieve this...i created a webpage with a button and published it. On button click i will run the batch file. but i don't know how to embed Mydesktopapp with webpage...so that it get published with it and get downloaded automatically when user open webpage.
I am new to WPF but yes..i don't want to create a WCF(or webservice etc ) instead i just want to enbed/attach this app with my webpage and get it downloaded automatically.
Please provide help.
Your solution is Silverlight or WPF browser application, since wpf is primarily a desktop application, I 'll recommend you to opt for silverlight for the web based solutions
From Microsoft's website
Silverlight is a powerful development tool for creating engaging, interactive user experiences for Web and mobile applications. Silverlight is a free plug-in, powered by the .NET framework and compatible with multiple browsers, devices and operating systems, bringing a new level of interactivity wherever the Web works.
more info on Silverlight at http://www.microsoft.com/silverlight/
This is based on C#. I am having a classlibrary in which I would like to know specifically if its being called from a windows based application
I searched a lot but all I found was code to know if it was called from a Console application.
I only want to know if its called from a windows based application or not
Please Help
If you want to know whether the application is running as a service or system app and thus cannot display a dialogue, test the state of Environment.UserInteractive.
There is no easy way to determine if the application is a windows or cmd-based application. For example, I might build a winforms-based application that doesn't create a window and instead runs as command-line style application by not opening a window.
Two (not necessarily reliable) ways of testing if it's a windows-based app would be to test Application.OpenForms (if it contains forms, then it's a windows app) or Environment.GetCommandLineArgs() (if 0 args, assume it's a windows app).
If you absolutely need to know whether the app is a console or windows one, then you need to step out of the world of managed code and start delving into the exe file using unmanaged C++ code. There is just one byte difference between the two in the PE header of the exe file: Subsystem is set to 2 for a windows app and 3 for a cmd app. See http://msdn.microsoft.com/en-us/library/ms809762.aspx and http://support.microsoft.com/kb/90493/en-us for details if you really want to do this.
We have a legacy software which was built in MS-Access (UI) but was using Sqlserver 2005 as database server.
The UI in Ms-Access has got Menus with different menu-items. But some of the menu-items doesn't have screens yet (incomplete). So we decided now to move to .net environment (i.e. .net web application). Here is my main question.
Firstly I want start working on the screens in .net (.net web application) which are incomplete for the menu-items in MS-Access. Secondly I will be completing the other screens which are now working in MS-Access UI. So how can I use/call .net web application screens when ever user clicks on menu-items in MS-Access UI.
Please suggest me.
Thanks
It not really practical to integrate screens built in Access with some web based forms. I not sure why or who or what was suggested to you that such an approach is EVER used in our industry.
You can most certainly launch any web form or web site or launch any URL form the Access client running on your desktop. The code to launch that URL is:
Application.FollowHyperlink "path to web form or site goes here"
So you can place a button or menu in an Access form to launch a web form, or even launch eBay if you want. However I do not think the issue (or solution) is the ability to launch some web form, but is having parts of the application talk to each other.
An application becomes useful since all the application parts can tightly talk to each other. Access is a great RAD tool due to great ease as to one form launching a report or another form and passing information. And all of that application can EASY share common code and routines that allows you to accomplish useful business tasks.
So when you click on a detail row in an Access grid of data (continues form), then launching another form to edit the one record takes one line of code. So an application is never really just a single standalone form to edit data, but the talking between the forms and use of code and how those objects dance together is what really makes an application useful. If an application was just forms with no code then I think we would be all out of job in this industry.
The model of how you navigate and build web applications is rather different then how Access works. I mean if you have 5 browsers open, which browser has some form to edit your data and which browser is watching videos on YouTube?
You really cannot approach such a half-baked system in which some forms are in Access and parts of the application are web, based. The only way this is practical is if the web forms do not need to work with or use any of the code in the client forms.
However, you CAN build web forms in Access 2010. In other words, in the Access client you can build both client forms and web forms. The client forms can call and use web forms (they run in the client) as regular forms and things like where clauses etc. will work). When you publish to the web, then ONLY the web forms run. Here is a video of an access application of mine, and note how at the half way point I run the same forms in a web browser:
http://www.youtube.com/watch?v=AU4mH0jPntI
However, the above ability in Access right now cannot work with sql server, and must use SharePoint (or the upcoming office 365).
So no question the concept of moving bits and parts out of an application to being web based makes sense (so your concept of not moving ALL of the applicaton out to the web makes sense). However, the parts being moved out to the web must make sense as web or stand alone and not require integration with the client forms (at least during use).
In other words if you have a legacy payroll system in Access now, but want employees to enter their payroll hours, then that new web part is separate from the payroll system. And no question the payroll system could take and pull hours from the new employee hour entry system that is web based.
However, the idea that menus and parts of the client based application will seamlessly launch and use the web browser parts makes no sense at all . Again this makes zero sense and you are barking up the wrong tree here. As noted, if the web part is really a separate business process, then there are some possibilities here.
Last but not least, you can certainly build a set of web services (application business code and logic that is separate from the UI) on the .net web site. This separate business layer could then be used by both the Access client forms and the web forms. However, once again such a setup likely suggests that you better off to build the application as web based anyway as the web based forms can talk and use the business code with greater ease then the client forms can – only exception here again is if you using Access web services, then both web or client forms can use the stored procedures and business routines you write to run server side.
Last but not least, perhaps your problem(s) are solved by increased connectivity, and not really the need for web based? I address this question in the following article of mine.
http://www.kallal.ca/Toweb/Index.html
I wrote a client/server program using windows form application in visual studio. Now i want to put this program onto a web page, so on the client side they can just go onto any browser and and access the server.
Can i just embed the program i already hav onto a webpage or do i need to rewrite it using visual studio web application or maybe web services?? If so, will it be any different than a regular windows form application?
Sorry, you'll have to rewrite it. Your windows forms application runs on the client, but you want to run it through the browser, where it would have to run on the server.
If you've followed good design principles, the core functionality of your app will not be in the forms, but in classes (hopefully in a class library) that are not specifically tied to the UI. If that is the case, you'll just need to create a web front end (UI), and you can reuse the existing C# classes.
If, however, like many inexperienced developers, you've coupled the underlying logic tightly to the UI - a good example is putting code in the form's .cs file that's not really UI-centric - you're looking at a lot of refactoring, and THEN writing a web front end.
Perhaps you should have a look at ClickOnce deployment. I believe you can utilize it to download the WinForm app from a website.