如何将输入类型=文本转换为跨度

时间:2009-02-11 06:34:06

标签: asp.net

有没有办法在ASP.Net中将Input type = text转换为Span

1 个答案:

答案 0 :(得分:2)

您真的应该提供有关您想要执行此操作的方案的更多信息,但这里有几个通用的方法。

做服务器端

if(ChangeTextToSpan) { //some condition to check, could be a query string or what ever
  this.Label1.Text = this.TextBox1.Text;
  this.Label1.Visible = !this.TextBox1.Visibile = false;
}

做客户端

function swapTextBox(changeTextToSpan) {
  if(changeTextToSpan) { //again, do a condition
    var span = document.getElementById('<%= this.Label1.ClientID %>');
    var txt = document.getElementById('<%= this.TextBox1.ClientID %>');

    span.innerHTML = txt.value;
    span.style.display = 'inline';
    txt.style.display = 'none';
  }
}

setTimeout(10000, swapTextBox(true)); //after 10 seconds it'll swap
相关问题