[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Accessing asp.net controls from clientside javascript, PLS HELP!!!

Chris Wise

1/2/2003 12:17:00 PM

Hi,

Ive searched loads of places with no luck my problem is that I have a text
box,customervalidator and dropdownlist box.

I only want to check if the textbox holds any data if the dropdownlist is
visible or not, I have created clientside functions but I cant work out how
to access the asp.net controls i.e. to check visibility, value of the
textbox.

I also dont want to use <input type="text"......> but rather asp.net
controls.

Thanks

Chris


2 Answers

Jeppe

1/2/2003 12:32:00 PM

0

The dropdownlist when rendered is an HTML 'select' with the name of whatever
ID you give the list... if you set the visibility to false on the server
side it simply doesn't render it on the client side so it will not exist to
any client side code.

Therefore in the client side code check to see if the 'select' exists. if
not then it is not visible.

"Chris Wise" <chris@keytraffic.com> wrote in message
news:eFY#yBlsCHA.2296@TK2MSFTNGP09...
> Hi,
>
> Ive searched loads of places with no luck my problem is that I have a text
> box,customervalidator and dropdownlist box.
>
> I only want to check if the textbox holds any data if the dropdownlist is
> visible or not, I have created clientside functions but I cant work out
how
> to access the asp.net controls i.e. to check visibility, value of the
> textbox.
>
> I also dont want to use <input type="text"......> but rather asp.net
> controls.
>
> Thanks
>
> Chris
>
>


Kim Bach Petersen

1/2/2003 1:24:00 PM

0

> I only want to check if the textbox holds any data if the
> dropdownlist is visible or not, I have created clientside functions
> but I cant work out how to access the asp.net controls i.e. to check
> visibility, value of the textbox.

All asp.net controls has a ClientId property you can use to access it
clientside:

Dim strMyScript As String = ControlChars.CrLf & "<script
language=""javascript"">function Toggle() {document.getElementById('" &
MyControl.ClientId & "').style.display=document.getElementById('" &
MyControl.ClientId & "').style.display=='none' ? '' : 'none'}</script" & ">"
Page.RegisterClientScriptBlock("MyScript", strMyScript)

Kim :o)