Re: Accessing invisible control in Javascript

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hey thanks...
it worked :)


On Sep 25, 7:50 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@xxxxxxxxxxxx> wrote:
Leave Visible=true and hide controls with a css style display:none.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

<ipra...@xxxxxxxxx> wrote in message

news:1190730385.269145.204390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx





Hi All,

I have below label which is invisible when the page loads.
<asp:Label ID="lblTest" runat="server" Visible="false" Text="Test"></
asp:Label>

Now if I want to make this label visible on the web page, I used
below
javascript:
document.getElementById("<%= lblTest.ClientID %>").style.display =
"block";

But when the Javascript code is executed, I get below exception:
"Object required"

As per my observation, if the control is not loaded at the first time
then it will not have the client id and it will throw an exception.

Same is the case with DIV. I have 2 DIV's which are invisible on the
page load and in special cases I want to make one DIV visible and
make
other invisible then I get the above exception.

So, is there any way to make the controls visible/invisible
regardless
of their initial stage?

Please let me know ASAP.

Thanks in advance,
PI- Hide quoted text -

- Show quoted text -


.



Relevant Pages

  • Re: Question on Ajax vs. plain javascript
    ... your best option is client-side disabling with javascript. ... Software Developer ... Microsoft MVP ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Programmatically submitting a form
    ... You do it on the client with a javascript call myForm.sibmit; ... Software Developer & Consultant ... Microsoft MVP ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Session StageVariables
    ... Robbe Morris [Microsoft MVP - Visual C#] ... .NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes ... In IIS environment the process is restarted instead of simple shutdown but Session variables are lost and exception is logged into NT event log. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Cant put a throw statement in InfoMessage eventhandler?
    ... Microsoft MVP ... > I just checked it out and it turns out that SqlClient eats that exception. ... > statement around the invocation to the event handler. ... > you cannot throw an exception from the InfoMessage event and expect the ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: How do I conflate index page numbers in Word 203?
    ... It may seem disrespectful to abbreviate life dates, ... to make any exception for them; it does make an exception for inclusive ... Suzanne S. Barnhill ... Microsoft MVP (Word) ...
    (microsoft.public.word.docmanagement)