[C#]提交表单

简介: C#  Winform提交表表单的操作: //登陆 private void button1_Click(object sender, EventArgs e) { string name = textBox1.

C#  Winform提交表表单的操作:


//登陆
        private void button1_Click(object sender, EventArgs e)
        {
            string name = textBox1.Text.Trim();
            WebClient w = new WebClient();
            System.Collections.Specialized.NameValueCollection VarPost = new System.Collections.Specialized.NameValueCollection();

            VarPost.Add("type", "denglu");
            VarPost.Add("name", name);
            byte[] byRemoteInfo = w.UploadValues("http://192.168.1.180/handler/CheckUserName.ashx", "POST", VarPost);
            string sRemoteInfo = System.Text.Encoding.UTF8.GetString(byRemoteInfo);
            textBox1.Text = sRemoteInfo;
        }
        //离开
        private void button2_Click(object sender, EventArgs e)
        {
            string name = textBox1.Text.Trim();
            WebClient w = new WebClient();
            System.Collections.Specialized.NameValueCollection VarPost = new System.Collections.Specialized.NameValueCollection();

            VarPost.Add("type", "likai");
            VarPost.Add("name", name);
            byte[] byRemoteInfo = w.UploadValues("http://192.168.1.180/handler/CheckUserName.ashx", "POST", VarPost);
            string sRemoteInfo = System.Text.Encoding.UTF8.GetString(byRemoteInfo);
            textBox1.Text = sRemoteInfo;
        }

添加:
相关文章
|
1月前
|
XML JSON 前端开发
C#使用HttpClient四种请求数据格式:json、表单数据、文件上传、xml格式
C#使用HttpClient四种请求数据格式:json、表单数据、文件上传、xml格式
387 0
C#使用HttpClient上传文件(multipart表单)
C#使用HttpClient上传文件(multipart表单)
3556 0
|
Web App开发 前端开发 JavaScript
C# MVC提交表单的四种方式(转)
Mvc 提交表单的4种方法全程详解(转) 一,MVC  HtmlHelper方法 Html.BeginForm(actionName,controllerName,method,htmlAttributes){} BeginRouteForm 方法 (HtmlHelper, String,...
3023 0
|
Web App开发 JSON PHP
C#.net模拟提交表单POST
方法一 System.Net.WebClient WebClientObj        = new System.Net.WebClient();    System.
1115 0
|
C# 数据格式 JSON
C# 通过form表单下载文本文件
public void DownLoadConfigFile(string name) { //获取文件字符串内容 var data = _service.
833 0