Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

sqldatasource dal, wwwxxxenden, convert raid5 to raid 10 mdadm, apache force chunked, nrao wwwxxx, xxxxxdup, procmail change subject header, wwwXxx not20, Wwwxxx.doks sas, linux raid resync after reboot

Links

XODOX
Impressum

#1: Trying to hide an img control upon command

Posted on 2008-04-24 17:18:19 by Doogie

Hi I have an img control I am trying to hide upon certain types of
commands in my code behind. When to hide it is directly tied to a
asp:dropdownlist control. So depending on what the user selects in
that dropdownlist, this image will be hidden or be displayed.

I have tied the onselectedindexchanged value of the dropdownlist to a
c-sharp method (not javascript) because other things are being done as
well that I want to do server side. However, the img control is not
server side, I can't grab it on the c-sharp method.

So I tried to right something like this to do that

string myScript = "<script type='text/javascript'> if (imgTo != null)
{ imgTo.width = 0; }</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "ABC",
myScript);

However, it keeps saying imgTo is undefined. Even if I modify my
script above to read if (imgTo != 'undefined') it still gives me the
same error. But it's not undefined, below is my HTML for it.

<img alt="To Calendar" id="imgTo" src="../Images/calendar.gif"
style="width:0" onclick="CallCalendar('ctl00$MasterContentPlaceHolder
$txtTo')"/>

Is there something else I could be missing?

I have tried to use a server side image control instead of the client
side one, but once I do that, for some reason, it keeps losing the
data in my CallCalendar method (see above) that is called in the
onclick method for imgTo because it is posting back. That
CallCalendar method popups up a calendar and assigns the value
selected to a text box on the form. I have tried to put a break point
in my page load method to see why I lose the value in the text box,
but by the time it gets to page load the value in the text box is
already gone (although I can see it show up on the screen). So I'm
thinking the client side image is my best way, if I can just figure
out how to get it to realize imgTo is really thee.

Report this message

#2: Re: Trying to hide an img control upon command

Posted on 2008-04-24 18:10:49 by Madhur

I don't think you can refer the specified element directly using string id.

You will need to obtain DOM element by using
var obj =getdocumentelementbyid('imtTo')

and then perform the operations on it.

Hope this helps.

--
Madhur

"Doogie" <dnlwhite@dtgnet.com> wrote in message
news:41068cdc-442c-4135-847e-73e9b4d79914@m73g2000hsh.google groups.com...
> Hi I have an img control I am trying to hide upon certain types of
> commands in my code behind. When to hide it is directly tied to a
> asp:dropdownlist control. So depending on what the user selects in
> that dropdownlist, this image will be hidden or be displayed.
>
> I have tied the onselectedindexchanged value of the dropdownlist to a
> c-sharp method (not javascript) because other things are being done as
> well that I want to do server side. However, the img control is not
> server side, I can't grab it on the c-sharp method.
>
> So I tried to right something like this to do that
>
> string myScript = "<script type='text/javascript'> if (imgTo != null)
> { imgTo.width = 0; }</script>";
> ClientScript.RegisterClientScriptBlock(this.GetType(), "ABC",
> myScript);
>
> However, it keeps saying imgTo is undefined. Even if I modify my
> script above to read if (imgTo != 'undefined') it still gives me the
> same error. But it's not undefined, below is my HTML for it.
>
> <img alt="To Calendar" id="imgTo" src="../Images/calendar.gif"
> style="width:0" onclick="CallCalendar('ctl00$MasterContentPlaceHolder
> $txtTo')"/>
>
> Is there something else I could be missing?
>
> I have tried to use a server side image control instead of the client
> side one, but once I do that, for some reason, it keeps losing the
> data in my CallCalendar method (see above) that is called in the
> onclick method for imgTo because it is posting back. That
> CallCalendar method popups up a calendar and assigns the value
> selected to a text box on the form. I have tried to put a break point
> in my page load method to see why I lose the value in the text box,
> but by the time it gets to page load the value in the text box is
> already gone (although I can see it show up on the screen). So I'm
> thinking the client side image is my best way, if I can just figure
> out how to get it to realize imgTo is really thee.

Report this message

#3: Re: Trying to hide an img control upon command

Posted on 2008-04-24 18:32:29 by Doogie

On Apr 24, 11:10=A0am, "Madhur" <s...@df.com> wrote:
> I don't think you can refer the specified element directly using string id=
..
>
> You will need to obtain DOM element by using
> var obj =3Dgetdocumentelementbyid('imtTo')
>
> and then perform the operations on it.
>
> Hope this helps.
>
> --
> Madhur
>
> "Doogie" <dnlwh...@dtgnet.com> wrote in message
>
> news:41068cdc-442c-4135-847e-73e9b4d79914@m73g2000hsh.google groups.com...
>
>
>
> > Hi I have an img control I am trying to hide upon certain types of
> > commands in my code behind. =A0When to hide it is directly tied to a
> > asp:dropdownlist control. =A0So depending on what the user selects in
> > that dropdownlist, this image will be hidden or be displayed.
>
> > I have tied the onselectedindexchanged value of the dropdownlist to a
> > c-sharp method (not javascript) because other things are being done as
> > well that I want to do server side. =A0However, the img control is not
> > server side, I can't grab it on the c-sharp method.
>
> > So I tried to right something like this to do that
>
> > string myScript =3D "<script type=3D'text/javascript'> if (imgTo !=3D nu=
ll)
> > { imgTo.width =3D 0; }</script>";
> > ClientScript.RegisterClientScriptBlock(this.GetType(), "ABC",
> > myScript);
>
> > However, it keeps saying imgTo is undefined. =A0Even if I modify my
> > script above to read if (imgTo !=3D 'undefined') it still gives me the
> > same error. But it's not undefined, below is my HTML for it.
>
> > <img alt=3D"To Calendar" id=3D"imgTo" src=3D"../Images/calendar.gif"
> > style=3D"width:0" onclick=3D"CallCalendar('ctl00$MasterContentPlaceHolde=
r
> > $txtTo')"/>
>
> > Is there something else I could be missing?
>
> > I have tried to use a server side image control instead of the client
> > side one, but once I do that, for some reason, it keeps losing the
> > data in my CallCalendar method (see above) that is called in the
> > onclick method for imgTo because it is posting back. =A0That
> > CallCalendar method popups up a calendar and assigns the value
> > selected to a text box on the form. =A0I have tried to put a break point=

> > in my page load method to see why I lose the value in the text box,
> > but by the time it gets to page load the value in the text box is
> > already gone (although I can see it show up on the screen). =A0So I'm
> > thinking the client side image is my best way, if I can just figure
> > out how to get it to realize imgTo is really thee.- Hide quoted text -
>
> - Show quoted text -

I tried doing it this way (both with the way you had the case on
getdocumentelementbyid and the way I have it below). Neither one
worked. I get an "object expected error" now:

var a =3D getDocumentElementByID('imgTo');
if (a !=3D null)
{
a.width =3D 0;
}

Report this message