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

Discussion in 'ASP .Net' started by John Holmes, Apr 16, 2004.

  1. John Holmes

    John Holmes Guest

    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

    }
     
    John Holmes, Apr 16, 2004
    #1
    1. Advertising

  2. 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

    "John Holmes" <> wrote in message
    news:%23NN8$...
    > 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
    >
    > }
    >
    >
     
    Raymond Lewallen, Apr 16, 2004
    #2
    1. Advertising

  3. John Holmes

    Marina Guest

    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.

    "John Holmes" <> wrote in message
    news:%23NN8$...
    > 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
    >
    > }
    >
    >
     
    Marina, Apr 16, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rod  Snyder

    moving from form element to form element

    Rod Snyder, May 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    419
    Vidar Petursson
    May 29, 2004
  2. Shapper
    Replies:
    2
    Views:
    768
    Scott Mitchell [MVP]
    May 7, 2005
  3. Masudur
    Replies:
    12
    Views:
    1,047
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Mar 26, 2007
  4. mesut
    Replies:
    0
    Views:
    353
    mesut
    Sep 5, 2008
  5. Knut Krueger
    Replies:
    8
    Views:
    327
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page