asp:label control doesn't show up as a form element

J

John Holmes

I would like to turn on a label control in javascript with the onfocus event
of another control by setting the Visible property to true. When I try and
reference this label control it says "Microsoft JScript runtime error:
'document.Form1.lblSigGrantor' is null or not an object". I wrote a loop and
iterated through the elements for the form and this control doesn't show up.
Code listed below, please help.

Thanks,

John Holmes

---------- html code, the onfocus event of the OBJECT tag calls
javascript:OnSign(); .. OnSign() listed below ----
<table id=tblSigGrantor cellSpacing=0 cellPadding=0 border=1>

<tr>

<td>

<asp:label id="lblSigGrantor" name="lblSigGrantor"

runat="server" Width="100%" ForeColor="White"

Visible="False" BorderColor="#404040" BackColor="Red">

VIRTUAL SIGNATURE PAD FOR GRANTOR SIGNATURE

</asp:label>

</td>

</tr>

<tr>

<td>

<OBJECT id=SigPlus1 onblur="OnSave('XYZ','txtSigGrantor');"

style="LEFT: 0px; WIDTH: 320px; TOP: 0px; HEIGHT: 180px"

onfocus="javascript:OnSign();" height="75"

classid="clsid:69A40DA3-4D42-11D0-86B0-0000C025864A" name="SigPlus1"

VIEWASTEXT>

<PARAM NAME="_Version" VALUE="131095">

<PARAM NAME="_ExtentX" VALUE="4842">

<PARAM NAME="_ExtentY" VALUE="1323">

<PARAM NAME="_StockProps" VALUE="0">

</OBJECT>

</td>

</tr>

</table>

-------------------------------- OnSign(); ... javascript code
.....----------

function OnSign()

{

OnClear();

document.Form1.lblSigGrantor.Visible = true;

document.Form1.SigPlus1.TabletState = 1; //Turns tablet on

}
 
R

Raymond Lewallen

John,

Labels are not form elements, they are more directly document elements.
They convert to SPAN tags in HTML code, which are not attributues of a form
object. Lose the Form1. document.lblSigGrantor.Visible

HTH,

Raymond Lewallen
 
M

Marina

When a control's Visible property is set to False on the server, the HTML
for that control is not sent down at all. Since it isn't sent down - there
is no way to make it visible, since it doesn't exist.

You would have to do something like:
myLabel.Attributes.Add("style","visibility=hidden")
on the server, to set the visibility to hidden. Then, in javascript, you
would set it back to visible or whatever it is.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top