如何在C#中将HTML表单数据转换为POST数据?

时间:2015-12-28 12:05:39

标签: c# html post html-form

C#中使用<form name="myform" action="page.php"> <input type="text" name="mytext" value="default text"> <textarea name="mytextarea">content</textarea> <input type="password" name="mypass" value="12345"> <input type="hidden" name="myhiddenfield" value="code"> <input type="checkbox" name="mychb1" value="true" checked> <input type="checkbox" name="mychb2" value="true"> <input type="radio" name="myradio" value="radio2" checked> <input type="radio" name="myradio" value="radio1"> <select name="mychoice"> <option value="cherry">cherry</option> <option value="orange">orange</option> <option selected="" value="apple">apple</option> </select> <input type="submit" value="Submit"> </form> ,我可以获得页面的来源。想象一下,这个HTML源始终包含一个具有给定名称的表单,如下所示:

mytext=default text&mytextarea=content&mypass=12345&myhiddenfield=code&mychb=true&myradio=radio2&mychoice=apple

现在我想根据这些值制作POST数据:

mychb2

请注意,{{1}}未包括在内,因为未检查,并且每个页面源中的名称可能不同,并且表单中的元素可能多于或少于元素。

我怎么能这样做?

0 个答案:

没有答案