problem to clear label value from javascript

Posted by Abhi_patil under JavaScript on 8/12/2009 | Views : 9269 | Status : [Member] | Replies : 5
i want to clear label value from javascript.

so i have written this stmt to clear value..

document.getElementById('ctl00_ContentPlaceHolder1_lblGrpSum').value="";
document.getElementById('ctl00_ContentPlaceHolder1_lblGrpSum').innerHTML="";

the value is being "".

but in searver side code after clear value i am still getting it's content.

lblGrpSum.Text //not being clear.




Responses

Posted by: Majith on: 8/12/2009 [Member] Starter

Up
0
Down
Greetings Abhi,

Check whether you have cleared the corresponding label or any other labels.

clear the label on server side when binding the grid or performing any operation. add watch the label and check it.


Thanks

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Goldytech on: 8/13/2009 [Member] Bronze

Up
0
Down
Try to use innerText property of javascript
Hope this helps

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 8/14/2009 [Member] Starter

Up
0
Down
You will get the contents in server side as the State of the Label controls is being stored into the ViewState of the page.

So this will not work. Instead what you can do is that you can have a hidden field and store the value of the label in the hidden variable. when you are trying to clear the label value, clear the value of hidden field as well and in the server side get the value of the hidden field using Request.Form["hiddenFieldName"].ToString();

Hope this helps.

Thanks

Regards,
Raja, USA

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakhangarg on: 8/17/2009 [Member] [Moderator] Silver

Up
0
Down
Hi -

Use like this:
document.getElementById('<%=lblGrpSum.ClientID %>').innerHTML="";

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Chikul on: 12/10/2009 [Member] Bronze

Up
0
Down
Instead of using Label, Use Text Box. Make the Border Width=0.
So it'll seems like Label.
Now you can use the following to Clear it.

document.getElementById('ctl00_ContentPlaceHolder1_lblGrpSum').value='';

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response