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;
}
添加: