首页 > 解决方案 > 选择项目后如何更改列表组上特定项目的名称(或值)(Bootstrap 3 / c# / ASP .NET)

问题描述

我需要知道如何修改(更改名称)列表组(Bootstrap 3)。我有一个带有新名称的文本框,当然还有列表,在选择项目或按下按钮后,文本框上的名称需要是所选项目的新名称,所有这些都使用后面的代码.

<input runat="server" id="Text2" placeholder="New name" class="form-control" type="text" />

<div runat="server" id="List" class="list-group">
   <a href="#" class="list-group-item">Sample 1</a>
   <a href="#" class="list-group-item">Sample 2</a>
   <a href="#" class="list-group-item">Sample 3</a>
   <a href="#" class="list-group-item">Sample 4</a>
   <a href="#" class="list-group-item">Sample 5</a>
   <a href="#" class="list-group-item">Sample 6</a>
   <a href="#" class="list-group-item">Sample 7</a>
</div>

<asp:Button runat="server" ID="Button1" class="btn btn-success" Text="Change Name" />

到目前为止,我已经尝试了以下代码 + 添加runat="server"和 id 到列表中的所有项目。

protected void Page_Load(object sender, EventArgs e)
        {
            BtnaddBtn.Click += BtnaddBtn_Click;
        }

        private void BtnaddBtn_Click(object sender, EventArgs e)
        {
            string test = Text2.Value;
            item1.InnerHtml = test;
        }

此代码确实有效并且是预期的输出,但是,我不知道如何通过按下项目本身使其像这样工作。

任何帮助、建议或编辑将不胜感激。

标签: c#htmlasp.nettwitter-bootstrap-3

解决方案


推荐阅读