This is a migrated thread and some comments may be shown as answers.

making controls invisible with javascript

4 Answers 220 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
bob ter
Top achievements
Rank 1
bob ter asked on 26 Nov 2009, 01:05 PM
Hi,

Is there a way i can make the controls (radtxtbox, radcombobox etc) invisible with javascript, what i have so far is

var cboTask = "<%= cboTask.ClientID %>";
var Task = document.getElementById(cboTask).value;

if(Task.style.visibility == "visible" || Task.style.visibility == "")
            {
                Task.style.visibility = "hidden";
                alert('hidden set');
            }
            else
            {
                Task.style.visibility = "visible";
                alert('visible set');
            }
        }

but i dont think task.style.visibility is the correct syntax as it comes back as undefined. Can anyone help me out?

4 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 26 Nov 2009, 01:30 PM
Hello Bob,

I recommend you use the set_visible property as shown below:

RadComboBox
$find("RadComboBox1").set_visible(false);

RadTextBox
$find("RadTextBox1").set_visible(false);

RadTextBox Client Object

Let me know if you need further assistance.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sphengle
Top achievements
Rank 1
answered on 08 Apr 2010, 05:09 PM
Is it possible to set the initial client hidden or visible state in code behind?
 
I can't use .Visible = false as this will prevent the control rendering in the page and me subsequently being able to show it again with .set_visible( true ).

I can hide the control by doing this in code behind....

RadTabStrip1.Style.Add(

HtmlTextWriterStyle.Display, "none" );

 


...but when you try to make it visible again using .set_visible( true ) then it doesn't work. 

I suspect I may need to inject some javascript into the page via code behind that either shows or hides the control.






0
T. Tsonev
Telerik team
answered on 08 Apr 2010, 05:30 PM
Hello Sphengle,

In this case you must show the control like this:

$get("RadTabStrip1").style.display = "block";

I hope this helps.

Greetings,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Sphengle
Top achievements
Rank 1
answered on 09 Apr 2010, 04:06 PM
Many thanks - that did the trick.

After doing a bit of Googling I now see the difference between $get() and $find().  Although I never did find the officual MS docs on the subject.

Tags
General Discussions
Asked by
bob ter
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Sphengle
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or