jmasterx
jmasterx

Reputation: 54123

Label that turns into textbox when clicked?

Maybe there is a CSS style for this, but, I want my TextBox to look like a label. When it is focused, I want it to look like whatever CSS style is applied. I am using bootstrap so that would be the style.

Is there some way to do this?

I have a grid view that I want to allow the user to rename without using the Edit Mode.

Thanks

(EDIT)

I mean an editable label: see http://dotnetspeaks.net/post/exm/EditableLabel.aspx

Upvotes: 0

Views: 972

Answers (2)

Ruchi
Ruchi

Reputation: 1236

You can use textbox by making it appear label and making it textbox on click or on focus. (just an approach, question is bit confusing.)

<script type="text/javascript">
function TextBox2Label()
{
    var control=document.getElementById("<%=TextBox1.ClientID %>");
    control.style.borderStyle="none";
    control.style.backgroundColor="Transparent";
    control.style.fontStyle.fontColor="Black";    
    control.readOnly=true;
}        
</script>

Upvotes: 0

Brad Christie
Brad Christie

Reputation: 101614

Here's a wild guess (since the question itself is a bit vague):

input {
    border: none;
    padding: 2px;
}
input:focus {
    border: 1px solid black;
}

And, voila! (and a version that more traditional)

Upvotes: 1

Related Questions