c# - 选择项目后如何更改列表组上特定项目的名称(或值)(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;
}
此代码确实有效并且是预期的输出,但是,我不知道如何通过按下项目本身使其像这样工作。
任何帮助、建议或编辑将不胜感激。
解决方案
推荐阅读
- node.js - 如何在 Elasticsearch 中匹配同一查询的不同实例?
- javascript - React.js 中 ES5 和 ES6 构造函数的区别
- d3.js - 缩放 Vega 等高线数据以适合散点图尺寸
- hive - 如何在蜂巢中显示小数点?
- python - 使用布尔响应将列附加到数据框
- r - 在一行中找到最大值并返回列名
- php - 我无法运行 PHP Artisan Server
- git - git比较两个分支,其中包含一些具有不同哈希的常见提交
- dns - Which of these DNS records has priority?
- mercurial - Why is Mercurial ignoring some of my files?