ASP.NET Web窗体,相当于东西或类似像网页上的文本控制台 [英] ASP.NET Web Forms, Something equivalent or similar like a Console for Text on a webpage

查看:188
本文介绍了ASP.NET Web窗体,相当于东西或类似像网页上的文本控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中移动在一个简单的文本操纵程序,ASP.NET Web窗体。

I'm moving over a simple text manipulator program in C# to ASP.NET Web Forms.

我发现,ASP:标签S可以从code后面的改变,我找不到其他的列表ASP:??事用这样的文本框或文本域等我都试过,但他们都没有有效的ASP。

I have found that "asp:Label"s can be changed from the code behind, I can't find a list of other "asp:?things?" to use like textbox or textarea etc. I have tried but they are not valid for asp.

试图为一个标签,我不认为这是有可能做的多条线路。所以有另一种ASP:可以像一个控制台或显示多行?或者你也可以做多行带有标签?

Trying to do multiple lines for a Label I don't think is possible. So is there another "asp:" that can act like a console or show multiple lines? Or can you do multiple lines with a Label?

WebPage.aspx

WebPage.aspx

<asp:Label runat="server" id="Label1"></asp:Label>

codeBehind为WebPage.aspx

CodeBehind for WebPage.aspx

Label1.Text = ("My text I wanto change or add etc.");

我的问题:
我的C#code需要增加多条线路,我不认为这可以用标签来完成它只会显示阵列中的最后一个输出。

My problem: My C# code requires adding multiple lines, I don't think this can be done with Labels it will only show the last output in the array.

protected void ShowRawData(string[] rawData)
{
    for (int i = 0; i < rawData.Length; ++i)
        // Console.WriteLine(rawData[i])
        Label1.Text = (rawData[i]);
}

我怎么能显示出与ASP.NET和Web Forms阵列中的所有行?

How can I show all the lines in the array with ASP.NET and Web Forms?

推荐答案

您可以使用这些属性设置文本框:

You can use a Textbox with these properties set:

<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" ReadOnly="True" ></asp:TextBox>

有关显示数组中的所有行:

For showing all lines of the array:

protected void ShowRawData(string[] rawData)
{
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < rawData.Length; ++i)
    {
        sb.AppendLine(rawData[i]);
    }
    TextBox1.Text = sb.ToString();
}

这篇关于ASP.NET Web窗体,相当于东西或类似像网页上的文本控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆