Solved

Javascript alter innerHTML of asp:Label control

Posted on 2004-04-02
6
1,741 Views
Last Modified: 2008-03-10
I have:

ASPX

<asp:datagrid.....blablabla
   .....
   <EditItemTemplate>
       <tr>
         <td>
             <img class="ImageButton" src="../image/ico_exclude.gif"
              onclick="<%# _oForm.FindControl(Page.Controls, "lblRealizacao").ClientID %>.innerHTML='This appears on the page but not on server side!!!'>
             <br>
             <asp:Label id="lblRealizacao" CssClass="Description" runat="server" />
    </td>
</tr>


CS

// These lines returns "" (empty) instead of "This appears on the page but not on server side!!!"
((Label) _oForm.FindControl( Page.Controls,"lblRealizacao")).Text ....
lblRealizacao.Text ....


_oForm.FindControl is simple a recursive function that search the page.controls for the ID passed in the parameter.

Why??

Thank you!
0
Comment
Question by:3DGames
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:gillit
ID: 10743193
Besides an unbalanced number of quotes (maybe just a typo):
onclick="<%# _oForm.FindControl(Page.Controls, "lblRealizacao").ClientID %>.innerHTML='This appears on the page but not on server side!!!'>

To use the quotes inside the onclick="";
You should use \"
For example:
onclick="<%# _oForm.FindControl(Page.Controls, \"lblRealizacao\").ClientID %>";

Besides those syntax, I'm not familiar with it enough to know why it doesn't work.
0
 
LVL 7

Expert Comment

by:TransBind
ID: 10743308
take a look at this example
this is a common way of attaching javascript to your control
http://davidhayden.com/blog/dave/archive/2004/03/16/178.aspx
0
 

Author Comment

by:3DGames
ID: 10743676
No... the quotes are ok in the code, only here i've put some more. (this site layout sucks...)

And the example in the passed link have no usefull information on this case.
I'm using that on delete confirmation.

But here i want:
1-) that a javascript alter de value of a HTML span (asp:label).
2-) it DID it well
3-) after the post back, the value didn't came...it stayed at the client side (???)

Capice? Did I explained it well?
Sorry for my bad english.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Accepted Solution

by:
gillit earned 500 total points
ID: 10743922
Information are only sent back through forms from the client. Within the forms, the information is sent through inputs. So from what I understand, the problem is that your value is in a label which is not an input field.

I think what you need to do is somehow set the value in an input field (eg textbox, button, hidden) as well as changing the text. This will require that you have a way to retrieve the value.

Hoping this helps.
0
 

Author Comment

by:3DGames
ID: 10744085
Genius you are!!

In my ignorance I wouldn't realize it...

Thanks!
0
 
LVL 3

Expert Comment

by:gillit
ID: 10744478
Glad I could help.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question