首页 > 解决方案 > 我无法从文本框 HttpRequest c# 发送文本

问题描述

我试过这个,没关系。

但是文本框无法发送文本。text is null

    {
        //Thread chiadoanduoi2000 = new Thread(chiadoanduoi200);
        //chiadoanduoi2000.Start();
        //  chiadoanduoi2000.IsBackground = true;
        string doanDuoi2000 = textBox1.Text;
        HttpRequest http = new HttpRequest();
        http.AddHeader("apikey", "xxx");
        http.AddParam("input", "soem text here");
        http.AddParam("speed", "1.0");
        http.AddParam("encode_type", "0");
        http.AddParam("speaker_id", "3");
        string auido = http.Post("https://api.zalo.ai/v1/tts/synthesize").ToString();
        
        textBox1.Text = auido;
        textBox2.Text = auido;
        //File.WriteAllText("truyen.txt", outputTexts[i].ToString());
    }

但无法从文本框中发送文本以请求 api

{
        //Thread chiadoanduoi2000 = new Thread(chiadoanduoi200);
        //chiadoanduoi2000.Start();
        //  chiadoanduoi2000.IsBackground = true;
        string doanDuoi2000 = textBox1.Text;
        HttpRequest http = new HttpRequest();
        http.AddHeader("apikey", "xxx");
        http.AddParam("input", doanDuoi2000);
        http.AddParam("speed", "1.0");
        http.AddParam("encode_type", "0");
        http.AddParam("speaker_id", "3");
        string auido = http.Post("https://api.zalo.ai/v1/tts/synthesize").ToString();
        
        textBox1.Text = auido;
        textBox2.Text = auido;
        //File.WriteAllText("truyen.txt", outputTexts[i].ToString());
    }

请帮助我,非常感谢。

标签: c#httprequest

解决方案


提供textBox1.Text是一个文本框控件,默认创建后Text值会返回string.empty。

确保有电话沿线

文本框1 = 新文本框();

这通常由你处理。表单的设计器文件。


推荐阅读