我如何使用VisualBasic中的WebControls元素添加UL LI列表元素

发布于 2025-01-21 11:10:20 字数 281 浏览 2 评论 0原文

我正在一个旧项目中工作,创建一个用户控件,以添加将根据需要更改的代码。 我想添加一个列表元素,但我只找到属性来创建< select>使用< asp:listbox 的列表类型,但这不是那样我正在寻找

您知道如何使用global.system.web.ui.webcontrols生成< ul>或至少自从我的VB代码以来,至少修改其CSSClass属性。如果我可以使用循环生成列表项目,那就太神奇了。

提前致谢

I'm working in an old project creating a User Control to add code that will change as I need.
I'd like to add a list element but I only found the property to create list type of <select> using <asp:ListBox, but this is not that I'm looking for

Do you know how generate a <ul><li> elements using Global.System.Web.UI.WebControls? or at least modify its CssClass properties since my VB code. It'd be amazing if I can use a loop to generate the list items.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄暮涼年 2025-01-28 11:10:20

一种解决方案是在webform.aspx中添加bueltedlist

<asp:BulletedList ID="BulletedList1" runat="server"></asp:BulletedList>

然后在您的webform.aspx.vb中,您可以添加项目:

For i As Integer = 1 To 3
    BulletedList1.Items.Add("item" & i)
Next

如果您在Web浏览器中检查您的页面,您会看到这些页面等效于&lt; ul&gt;&lt; li&gt; html标签。

One solution would be to add a BulletedList in your WebForm.aspx:

<asp:BulletedList ID="BulletedList1" runat="server"></asp:BulletedList>

Then in your WebForm.aspx.vb you can add items:

For i As Integer = 1 To 3
    BulletedList1.Items.Add("item" & i)
Next

If you inspect your page in a web browser you will see these are equivalent to <ul><li> HTML tags.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文