在ASP.NET动态地创建标签(VB) [英] Create labels dynamicly on ASP.NET (VB)

查看:86
本文介绍了在ASP.NET动态地创建标签(VB)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网页创建标签动态地,比如用户将在文本框中的数字标签,我会显示该标签具有的.text =XYZ。

I want to create labels in my page dynamicly, for example the user will choose in a textbox the number of labels, and I will display the number of this label with .text = "XYZ".

感谢。

推荐答案

快速和肮脏的方法(本例中增加了10个标签和文字到ASP.NET页面上的占位符:

The quick and dirty method (this example adds 10 labels and literals to a PlaceHolder on an ASP.NET page:

Dim c As Integer = 0
While c < 10
    Dim lab As New Label()
    Dim ltr As New Literal()
    lab.Text = c.ToString()
    ltr.Text = "<br/>"
    PlaceHolder1.Controls.Add(lab)
    PlaceHolder1.Controls.Add(ltr)
    C+=1
End While

这篇关于在ASP.NET动态地创建标签(VB)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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