我们如何发布数据表格c#Winform To网页 [英] How can We post the Data Form c# Winform To Webpage

查看:63
本文介绍了我们如何发布数据表格c#Winform To网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...,



我想开发Windows应用程序,因为它有一些数据字段(文本框,组合框,... )与浏览器中的网页相同,我们可以从本地数据库中检索数据。我想将此数据发布到浏览器中运行的网页的相应字段,是否可能.......请建议我如何做......

< br $>






问候。

SriramNidamanuri

Hi All...,

I want to Develop Windows application ,which works as it has some data fields (text Boxes, Combo boxes,...)same as web page in browser,we can retrieve data from Local database. i want to Post This Data to corresponding fields of webpage running in the browser ,Is it possible or not.......Please Suggest me How it will Do......




Regards.
SriramNidamanuri

推荐答案

您可以使用查询字符串 [ ^ ]



查看此文章为例

免费Geocoder.us网络服务c# [ ^ ]



编辑
查看这些MSDN链接

如何:使用WebRequest类发送数据
[ ^ ]

如何:使用WebRequest类请求数据 [ ^ ]



使用C#应用程序发送HTTP Web请求 [ ^ ]

以编程方式将数据发布到ASP .NET Web应用程序 [ ^ ]
You can use querystring[^]

Check this article for example
Free Geocoder.us web service in c#[^]

EDIT
Check these MSDN links
How to: Send Data Using the WebRequest Class
[^]
How to: Request Data Using the WebRequest Class[^]

Send HTTP Web Request using C# Application[^]
Programmatically Posting Data to ASP .NET Web Applications[^]


查询字符串是不是一切,这不是主要部分,并不总是使用。你真的需要使用类 System.Net.HttpWebRequest ,但你的编译时变量将是类 System.Net.WebRequest 因为运行时类型是由作为工厂方法的参数传递的URI定义的。 创建,请参阅:

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx [ ^ ]。



请参阅上面引用的第二篇文章中的代码示例,但这是针对HTTP方法'get'(默认),但您需要使用'post'。



您可以在此处找到帖子示例: http://www.jigar .net / howdoi / viewhtmlcontent106.aspx [ ^ ]。忽略这个事实,这是ASP.NET样本 - 有什么区别。



你需要做的是找出要写入请求字符串的帖子字符串(再次参见上面的示例)。它取决于服务器部分所期望的表单数据;这是您需要在请求中模拟的数据。注意表单中的名称属性。您需要通过在请求流中写入这些名称和值来发送它们。基本上,名称/值对的编写格式与URL中使用的查询字符串相同;在上面引用的代码中查看示例格式字符串 field1 = {0}& field2 = {1} 。在此示例中,Web窗体控件中的name属性为 field1 field2 ,并且值由Web表单用户的输入。您可以使用post字符串模拟此输入,如上例所示。



-SA
Query string is not everything, and this is not main part and not always used. You really need to use the class System.Net.HttpWebRequest, but your compile-time variable will be of the class System.Net.WebRequest as the run-time type is defined by URI passed as a parameter of it factory method. Create, see:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx[^].

See the code sample in the second article referenced above, but this is for HTTP method 'get' (default), but you will need to use 'post'.

You can find a 'post' sample here: http://www.jigar.net/howdoi/viewhtmlcontent106.aspx[^]. Ignore that fact that this is ASP.NET sample — what's the difference.

Main thing you need to do is to find out what post string to write to the request string (again, see the sample above). It depends on the form data which is expected by the server part; and this is the data you will need to simulate in your request. Pay attention to the "name" attributes in your form. You will need to send those names and values by writing them in your request stream. Basically, the name/value pairs are written in the same format as the query string used in URL; look at the sample format string "field1={0}&field2={1}" in the code referenced above. In this example, the "name" attributes in the Web form's control are field1 and field2 and the values are defined by the input of the user of the Web form. You simulate this input using the post string like in the example shown above.

—SA


通过在请求流中写入它们来实现。基本上,名称/值对的编写格式与URL中使用的查询字符串相同;查看上面引用的代码中的示例格式字符串field1 = {0}&field2 = {1}。在此示例中,t
alues by writing them in your request stream. Basically, the name/value pairs are written in the same format as the query string used in URL; look at the sample format string "field1={0}&field2={1}" in the code referenced above. In this example, t


这篇关于我们如何发布数据表格c#Winform To网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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