•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,648 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,866 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 12217 | Replies: 5
![]() |
Hi all..
I am having some controls in my aspx page.I need to write javascript for those controls for validation..For that i need to make the controls visible false in certain situation .I also want to make the controls to visible true in certain sitauations..Some one help me with javascript code for this..
Regards,
Balagurunathan S
I am having some controls in my aspx page.I need to write javascript for those controls for validation..For that i need to make the controls visible false in certain situation .I also want to make the controls to visible true in certain sitauations..Some one help me with javascript code for this..
Regards,
Balagurunathan S
•
•
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation:
Rep Power: 7
Solved Threads: 58
There are many ways to show/hide, render/not render a control
For ASP.NET webcontrols you have the Visible property which can be set to true or false but that's serverside.
For client side you have visibility attribute in CSS which can be "visible" or "hidden", here is an example:
For ASP.NET webcontrols you have the Visible property which can be set to true or false but that's serverside.
For client side you have visibility attribute in CSS which can be "visible" or "hidden", here is an example:
asp Syntax (Toggle Plain Text)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ControlVisibilityClientSide.aspx.cs" Inherits="ControlVisibilityClientSide" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>ControlVisibilityClientSide</title> <script type="text/javascript"> function toggleVisibility(controlId) { var control = document.getElementById(controlId); if(control.style.visibility == "visible" || control.style.visibility == "") control.style.visibility = "hidden"; else control.style.visibility = "visible"; } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <input type="button" ID="btnShowHide" value="Show/Hide" onclick="toggleVisibility('TextBox1');" /></div> </form> </body> </html>
•
•
Join Date: Feb 2005
Location: Braintree, UK
Posts: 1,164
Reputation:
Rep Power: 7
Solved Threads: 58
Yes it is, an asp:Button will cause a postback and you can make controls visible property true/false server side. The OP asked for javascript to show/hide controls on the page client-side. The only reason to show/hide controls with javascript is because a postback serverside is a lot of network and server resources re-constructing a whole page just to hide/show one or two controls. So, as we were discussing client-side code an asp:Button was not necessary.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- Make a VB Program run in the background? (VB.NET)
- to make checkboxes visible in datagrid C# windows application (C#)
- checkbox in datagrid (ASP.NET)
- Getting values from GridView Controls (ASP.NET)
- Problems with Directory.Move (C#)
- owner form display problem (VB.NET)
- Timing frames on a form (Visual Basic 4 / 5 / 6)
- Control array (Visual Basic 4 / 5 / 6)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Firefox, javascript and document object
- Next Thread: returning array from ajax.responseText?



Linear Mode