tags:

views:

39

answers:

1

Is there a way to convert Input type=text to Span in ASP.Net

+2  A: 

You really should provide more information about the scenario you'd want to do this for, but here's a couple of generic ones.

Doing it server side

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;
}

Doing it client side

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
Slace