Asp:Imagebutton and javascript

J

JIM

Hello,

I've an asp:Imagebutton on my form with the visible property set to false

<asp:Imagebutton ID="tstImage" runat=Server visible=False>

How can I set the visible propery to true using a javascript ?
I tried something like document.GetElementById('ImgTest').visible='true';
but without succes ....

Any idea ?

Many thanks,

KArel
 
R

Roland Hall

in message : I've an asp:Imagebutton on my form with the visible property set to false
:
: <asp:Imagebutton ID="tstImage" runat=Server visible=False>
:
: How can I set the visible propery to true using a javascript ?
: I tried something like document.GetElementById('ImgTest').visible='true';
: but without succes ....
:
: Any idea ?

Jim...

Isn't that an ASP.NET image button? This is Classic ASP. NG replies
updated.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
D

darrel

How can I set the visible propery to true using a javascript ?
I tried something like document.GetElementById('ImgTest').visible='true';
but without succes ....

You can't. If you're setting the visibility on the control, then that's
being controlled by the codebehind. If it's set to be visible="false" it
won't even be rendered in the HTML.

For what you want, I think you want to place the button in a DIV and then
HIDE the div via javascript when the page loads. That way it's part of the
DOM and you can then do what you want with it via javascript.

-Darrel
 
B

Bob Barrows [MVP]

JIM said:
Hello,

I've an asp:Imagebutton on my form with the visible property set to
false

<asp:Imagebutton ID="tstImage" runat=Server visible=False>

How can I set the visible propery to true using a javascript ?
I tried something like
document.GetElementById('ImgTest').visible='true'; but without succes
....
You can't. When its visible property is set to false, it is not rendered in
the client, so there is nothing there on which the clientside code can act.

What you have to do is set its visible property to true. That way there will
be an html element in the client DOM on which client-side code can act.
You can set its display style to none in the body onload event. You can set
it to inline or block in whatever event you are thinking of using to set it
to visible.


Bob Barrows
PS. microsoft.public.inetserver.asp.general is for classic ASP questions. I
have removed that group from the crosspost.
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top