Answer the question
In order to leave comments, you need to log in
How to send a POST request as data from a textbox form?
There is an application in C #, it has a textbox form from which, when the button is pressed, the entered data should be retrieved, and a POST request should be sent with them
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections.Specialized;
using System.Net;
namespace std
{
public partial class Form1 : MetroFramework.Forms.MetroForm
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void MetroTextBox1_Click(object sender, EventArgs e)
{
}
private void BunifuButton1_Click(object sender, EventArgs e)
{
using (WebClient client = new WebClient())
{
byte[] response = client.UploadValues("http://ccылка.ru/api", new NameValueCollection() {
{ "phone", "тут должны быть данные из textbox" },
{ "message", "Hello world" },
{ "key", "key" },
});
string result = System.Text.Encoding.UTF8.GetString(response);
}
}
}
}
Answer the question
In order to leave comments, you need to log in
And what exactly is the problem?
To take data from a textbox, this is the MetroTextBox1.Text property, and if there are problems with POST,
here are examples, study:
https://carldesouza.com/httpclient-getasync-postas...
https://csharp. hotexamples.com/en/examples/-/HttpC...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question