正在获取asp.net中literal1.text的值



我想问一下如何在literal1.text.中获取<span>标记内的值

这是我的密码。

Literal1.Text = Literal1.Text & "<div class='chip' style='padding:8px;display:inline-block;border-radius: 25px;background:white;color:black;'><span>" & TextBox3.Text & "<i class='close fa fa-times'></i></span></div> &nbsp;"

我在我的项目中把它当作一个标签盒。

这是的屏幕截图

或者,如果你对如何在asp.net网页表单中创建标签框有任何建议,我可以轻松地检索数据并将其保存在数据库中。我真的需要并将感谢你的帮助!

提前感谢!

我会在Textbox周围使用formview将Tags插入数据库,然后检索它并使用Repeater插入。

将查询添加到SqlDataSource中,然后编辑绑定到列名的名称。

请注意,我还没有测试过,但据我所知,它应该有效。


<asp:FormView runat="server" id="FormView1" DataSourceID="SqlDataSource1">
<InsertItemTemplate>
<asp:TextBox runat="server" id="TextBox1" Text='<%# Bind("TagName") %>'></asp:TextBox>
<asp:Button runat="server" id="InsertButton" CommandArgument="Insert"></asp:Button>
</InsertItemTemplate>
</asp:FormView>

<asp:Repeater runat="server" id="Repeater1" DataSourceID="SqlDataSource1">
<ItemTemplate>
<div class='chip' style='padding:8px;display:inline-block;border-radius: 25px;background:white;color:black;'>
<asp:Label Text='<%# Bind("TagName") %>'></asp:Label>
</div>
</ItemTemplate>
</asp:Repeater>

<!-- Add here your database querys for insert and select -->
<asp:SqlDataSource runat="server" id="SqlDataSource1"></asp:SqlDataSource> 

最新更新