Y "object expected" ?

G

Guest

Hi,
I have problem to get the control id and set its visible to true/false(mean
show/hide).

here is my code:
<%@ Control Language="vb" AutoEventWireup="false"
Codebehind="ucNavbar.ascx.vb" Inherits="UserInterfaceDesign.ucNavbar"
TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>

<A id="hpL" href="" DESIGNTIMEDRAGDROP="59" runat="server"
onmouseover="window.status='<I>text to display in status bar</I>'; return
true;">
Make Request</A>

<asp:linkbutton id="lbtnSupport" runat="server"
Width="104px">Support</asp:linkbutton>
<asp:linkbutton id="lbtnLogoff" runat="server">Log off</asp:linkbutton>
<DIV id="divNavmakereq" style="VISIBILITY: visible; WIDTH: 144px; POSITION:
relative; HEIGHT: 100px; BACKGROUND-COLOR: aqua"
runat="server" ms_positioning="GridLayout"><INPUT style="Z-INDEX: 101;
LEFT: 8px; POSITION: absolute; TOP: 8px" type="button" value="Yahoo"></DIV>


<script type="text/javascript">
function fn_mouseoverjavascript(){
alert(document.getElementById('divNavmakereq');
}

</script>

in the javascript function, i try to show the control name, the error
message prompt:
object expected. Actually my concern is to show / hide the divNavmakereq
control.

have any ideas?
I already out of ideas.
thank you in advance.

best regards,
GL
 
G

Grant Merwitz

Have you checked the name of the DIV tag.

When you use controls, generally your TAGS are renamed UC1_IDNAME (or
something like that)

Double check the ID name like this:
When you are viewing the Webpage in IE, click View --> Source
Look at the DIV tag you are trying to use, and check its name has not
changed from divNavmakereq to something else
If it has, thats your problem, just update you JavaScript with the right
ID name

alert(document.getElementById('TheNameYouFindInTheSource'); //not sure
what you trying to do with that line, might need to add ID in there to get a
value

But what you really want is
document.getElementById('TheNameYouFindInTheSource').style.visibility =
"hidden";
 
G

Guest

HI Grant Merwitz,
thanks for ur respond.
i have a question, actually the source code is from user control page.
i try to show/hide the divNavmakereq.
So, the technique is still same as u replied to me ?
 
G

Grant Merwitz

oh, HAHA

I was writing the reply but got distracted.

Well, waste not want not.

Here's what i was saying:


as this div tag has a Runat=server, when this control is implemented into
you page, it will rename it with the TagName you specified.

so, if you register you tag like so:

<%@ Regoster TagPrefix="uc1" TagName="MyControl" ...

and you called your Div Tag 'divNavmakereq'

This will be renamed at run time to :
MyControl_divNavmakereq - or something like that

So, when you testing your control, on the page its being used (aspx), view
the source of that page and get its ID.
Bearing in mind, this control will have to have the same TagName wherever it
is used - or this code will not work in that instance.

There's also probably a better way of doing this that its not dependent on
the ID so much, like passing the control to your JavaScript.
But this will work
 

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,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top