从Windows窗体中的TextBox获取文本并将其放入Web应用程序的TextBox中 [英] Getting text from TextBox in Windows Form and putting it in TextBox of Web Application

查看:68
本文介绍了从Windows窗体中的TextBox获取文本并将其放入Web应用程序的TextBox中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



一般来说我对编程比较陌生 - 我参加的最后一个正式的面向对象编程课程是我一年级大学(我的行话可能是不准确)。所以拜托,请耐心等待。如果这个问题应该在不同的领域(例如C#论坛,请告诉我)。



基本上,前提是:在一个解决方案中,我有两个项目,Windows窗体应用程序和Web应用程序。我的Windows窗体应用程序将是一个简单的GUI(稍后会变得更复杂,但我想开始更简单地开始),标签提示用户输入一些文本,TextBox用于输入文本,以及提交按钮。按下提交按钮后,我想将输入的内容传递到TextBox中以显示在给定网页上的TextBox中(此网页将成为已存在的Web应用程序的一部分但是现在我只是使用本地主机进行调试并且让概念失效了。



我已经为Windows表单应用程序设计了表单并设计了网页(再次简单,标签上写着从GUI输入的文本 :和TextBox)。所以现在我被卡住了。我尝试了几种不同的东西,并尝试寻找类似的问题,但没有这样的运气。我以为我可以使用我的Windows窗体项目的名称(在aspx.cs页面中)实现一个using命名空间,但是当我运行时,它无法识别我使用的方法...所以我尝试了把方法直接在.aspx页面,但它不喜欢我给出的命名空间(询问我是否缺少程序集引用...我不是...)。



我觉得我比这更困难,我不知道从哪里开始。如果有人需要查看我的代码,我会发布它 - 我现在会发布它,但这有点麻烦。我正在编程的计算机不允许连接到Internet,我也不允许使用拇指驱动器等设备,因此我必须手动输入。但是,如果这意味着我可以得到一些答案,我愿意这样做!再次,我在这里学习和寻求建议,所以任何帮助将非常感谢!此外,快速响应是理想的!



哦!我正在使用Visual Studio 2012,.NET Framework 4.5和我的Windows窗体应用程序是用C#编写的。

解决方案

问题清楚地表明你不知道你是什么尝试做,并不知道.NET编程。例如,您不了解引用,更一般地说,使用程序集并且可能认为使用指令以某种方式帮助使用程序集(它不会,它只是更改程序集级别类型的命名规则允许缩短其使用中的名称。因此,有了这样的理解水平,做任何Web甚至只是UI开发还为时过早。首先,您需要学习编程的基础知识,这对于简单的仅限控制台的应用程序来说要容易得多。无论如何,在ASP.NET应用程序中使用 System.Windows.Forms 毫无意义,因为所有.NET代码都在服务器端工作;出于同样的原因,在任何桌面应用程序中使用大多数ASP.NET类都没有任何意义。



同时,问题相对容易。在客户端,您只需要发送一些带有适当数据的HTTP请求和一些URL: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=vs.110%29.aspx [ ^ ]。



在服务器端,你应该在这个URL上有一些ASP.NET应用程序。应用程序应从HTTP请求中获取数据,并根据数据生成某些HTML内容。这就是HTTP请求在服务器端的表示方式: http://msdn.microsoft.com/en-us/library/system.web.httprequest%28v=vs.110%29.aspx [ ^ ]。



一些使用示例显示在上面引用的MSDN页面的末尾。



-SA

Hello all,

I am relatively new to programming in general - the last formal object oriented programming class I took was my freshman year of college (my jargon may not be accurate). So please, bear with me. If this question should be asked in a different area (such as the C# forum, please let me know).

Basically, the premise is this: in one solution I have two projects, a Windows Form Application and a Web Application. My Windows Form Application will be a simple GUI (it will get more complicated later but I wanted to started more simply to start) with a label prompting the user to input some text, a TextBox for the user to input the text, and a Submit button. Once the Submit button is pressed I want to pass whatever was typed into the TextBox to appear in a TextBox on a given webpage (this webpage will be part of a Web Application that already exists but for now I am just using a local host for debugging and getting concepts down).

I have already designed the form for the Windows Form Application and designed the web page (again simple with a label stating "Text Entered from GUI:" and a TextBox). So now I'm stuck. I've tried a couple of different things and tried searching for a similar problems but no such luck. I thought that I could implement a "using" namespace with the name of my Windows Form project (in the aspx.cs page) but when I run, it doesn't recognize the method I use...so I tried putting the method directly in the .aspx page but it doesn't like the namespace I've given (asked if I was missing an assembly reference...which I am not...).

I feel like I am making this more difficult than it needs to be and I am not sure where to go from here. If someone needs to look at my code I will post it - I would post it now but it is a bit of a hassle. The computer I am programming on is not allowed to be hooked up to the Internet, nor am I allowed to use devices such as thumb drives, so I will have to type it in by hand. However, I am willing to do this if it means I can get some answers!! Again, I am here to learn and seek advice so any help would be GREATLY appreciated! Also, a speedy response is ideal!

Oh! I am using Visual Studio 2012, .NET Framework 4.5 and my Windows Form Application is written in C#.

解决方案

The question clearly shows that you have no idea what you are trying to do, and have little idea of .NET programming. For example, you don't understand referencing, and, more generally, using assemblies and probably think that using directive somehow helps to use the assembly (it does not, it merely changes the naming rules for assembly-level types, allows to shorten the names in their use). So, with such level of understanding, doing any Web even just UI development would be premature. First, you need to learn the basics of programming, which is much easier to do with simple console-only application. Anyway, using System.Windows.Forms in ASP.NET application makes no sense at all, because all .NET code works on the server side; by the same reason, there is absolutely no sense in using most ASP.NET classes in any "desktop" applications.

At the same time, the problem is relatively easy. On the client side, you just need to send some HTTP request with appropriate data with some URL: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest%28v=vs.110%29.aspx[^].

On server side, you should have some ASP.NET application at this URL. The application should take the data from HTTP request and, depending on the data, produce certain HTML content. This is how the HTTP request is represented on the server side: http://msdn.microsoft.com/en-us/library/system.web.httprequest%28v=vs.110%29.aspx[^].

Some examples of the usage are shown at the end of the MSDN page referenced above.

—SA


这篇关于从Windows窗体中的TextBox获取文本并将其放入Web应用程序的TextBox中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆