Click here to Skip to main content
15,886,036 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi friends I need your valuable answer send as early as possible

My Question is "How to change the style of textbox to label and Viz..after clicking edit button"

I have a asp.net listview in that I have to show the employee name as label first then after clicking Edit i need to change label to textbox (i.e. with out taking label I have to use textbox as label) ...
<listview id="lvid" runt="server">
<asp:label id="label1" Text='<%#Eval("emloyeename")%>' runat="server" visible="true" />
 <asp:Textbox id="Textbox1" Text='<%#Eval("emloyeename")%>' runat="server" visible="false" />
</listview>

now the above code will be executed fine... but I want to change lable to textbox by clicking edit button

Thanks in advance
Posted
Updated 25-Sep-14 4:03am
v3
Comments
Thanks7872 25-Sep-14 9:35am    
"with out taking label i have to use textbox as label"

Did you drink a lot last night?
Richard MacCutchan 25-Sep-14 9:54am    
Yes, "alot" is my favourite drink. :)

1 solution

You could have a listview with textbox with readonly flag set to true. Clicking edit would simply change that to false.

jQuery:
JavaScript
//On edit click
$("#your-list-id input").attr("readonly", "false");

//on save and load
$("#your-list-id input").attr("readonly", "true");
 
Share this answer
 
v2
Comments
yedhuvamshi 25-Sep-14 9:40am    
Thank u for your reply..
But i have n number of textboxes so i need to give all n number of textboxes to readonly =true
is there any thing with css for at a time changing of all textboxes
Sinisa Hajnal 25-Sep-14 9:48am    
So, edit changes all labels? what is preventing you from using javascript or jQuery so that you change all on click? You cannot mark input box readonly via CSS.

And if you would play with visibility, again you need javascript which then returns us to the above point of using it to change the attribute to / from readonly.
Thanks7872 25-Sep-14 10:04am    
If above solution works the way you want than you can make use of class. That is

$(".ClassNameHere").attr("readonly", "false");

$(".ClassNameHere").attr("readonly", "true");


Apply this class to all your textboxes.
Sinisa Hajnal 25-Sep-14 10:16am    
Why? #list-id input will take all textboxes within the list (assuming of course that is only textbox in the list) - you don't need to add class to each...even if it is only one of several in the row of the list you could use nth-child selector
Thanks7872 25-Sep-14 10:23am    
I don't know about OP's design,but applying class would make it easier to apply something to all the textboxes. There can be other controls also.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900