vakas
vakas

Reputation: 1817

how to make a part of the textbox as readonly

i have a tagtextbox on my page when a user selects a category that category name goes to tagtextbox

now i want that this category name user cant change but he can append some more tags means first tag becomes readonly and further he can add too in same text box

Upvotes: 1

Views: 1623

Answers (5)

Maroof Ahmad
Maroof Ahmad

Reputation: 21

CSS :

<style type="text/css">
.div {
   margin:20px; 
   padding:10px; 
   background:#ccc; 
   float:left;
}

.textarea {
   border:0; 
   display:block; 
   font-size:12px; 
   padding:5px 5px 0; 
   outline:none; 
}

.span {
   display:block;
   background:#fff;
   font-size:14px;  
   padding:5px 5px 5px; 
   color:green; 
   outline:none;
}
</style>

HTML :

<div class="div">
<div class="span">
<asp:TextBox runat="server" ID="txtNumber" BorderStyle="None" />
<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator1" ValidationExpression="\d+" ControlToValidate="txtNumber" ErrorMessage="Only Numbers are allowed" Display="Dynamic" />
</div>    
</div>

Upvotes: 2

andy boot
andy boot

Reputation: 11727

Adding to what SLaks said - Here is an example of a CSS & HTML hack where someone has added a span under the textbox. To make it look like it is part of the same textbox there is a border round the enclosing div. It looks quite effective.

textbox with uneditable name at the bottom

Upvotes: 0

SLaks
SLaks

Reputation: 887375

This is not possible.

Instead, you can put the first category name in a <span>, and put the textbox after the span.
You can then apply border: none to the textbox and make your own border around the entire thing to make it look like a single textbox.

Upvotes: 2

fmsf
fmsf

Reputation: 37137

If you want to allow append has in "paste" action, then you can't do that. Else and you just want to append via your code, why not use just a div to show what he has selected and add the selections to your post on a hidden textbox?

Upvotes: 0

Justin Niessner
Justin Niessner

Reputation: 245419

You can't make part of a textbox editable and another not.

My suggestion would be to change the type of element from a TextBox to a div or span via Javascript as soon as the user begins to enter the next tag.

Upvotes: 0

Related Questions