473,769 Members | 4,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Example of showing/hiding panels

Hi There,
Should I be able to show and hide panels in an asp.net page without
requiring a postback? I thought there was a way to do this using java
script. Can anyone give me an example? I can't seem to find one that makes
sense. Thanks.

Nov 18 '05 #1
3 2566
you'll have to get the clientside names but bascially something like

controlName.sty le.display = 'none' (then '' or 'block')
--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Charlie Dison" <ch************ ****@vitalworks .com> wrote in message
news:Xk******** ********@newssv r32.news.prodig y.com...
Hi There,
Should I be able to show and hide panels in an asp.net page without
requiring a postback? I thought there was a way to do this using java
script. Can anyone give me an example? I can't seem to find one that makes sense. Thanks.

Nov 18 '05 #2
Hi Charlie,

As for the ASP.NET Panel WebServer control, when the page is rendered out
to client , the Panel will be output as a
<div> html element. And as Curt has mentioned, we can generally use the
"display" style attribute to control the html element's visible. For
example, if here is a Panel rendered as

<div id="MyPanel" ...> ...</div>

We can use the following script code to hide it.

document.getEle mentById("MyPan el").style.disp lay = "none";

And here is a demo page I made to show the above means, you can have a look
if you have anything unclear:

=============as px page=========== ========
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>ManPanel </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<script language="javas cript">
function ShowElement(id)
{
var elm = document.getEle mentById(id);
elm.style.displ ay = "";
}

function HideElement(id)
{
var elm = document.getEle mentById(id);
elm.style.displ ay = "none";
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table width="100%" align="center">
<tr>
<td>
<asp:Panel id="Panel1" runat="server">
<P><FONT face="ËÎÌå">Her e is Panel1<BR>
<asp:TextBox id="TextBox1" runat="server"> </asp:TextBox>
<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button></FONT></P>
</asp:Panel>
</td>
</tr>
<tr>
<td>
<INPUT id="btnShow" type="button" value="Show"
onclick="ShowEl ement('Panel1') ;">
<INPUT id="btnHide" type="button" value="Hide"
onclick="HideEl ement('Panel1') ;">
</td>
</tr>
</table>
</form>
</body>
</HTML>
=============== =============== ===============

Hope also helps. Thanks.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
Hi Charlie,

Thanks for your followup. Yes, it can't span rows in a table because the
Panel is actually a <div> html element and the
rows in table is just like

<table>
<tr>
...
</tr>
<tr>
...
</tr>
</table>

they are a single html element and is not spanable by another html
element:). Anyway, I'm glad that my suggestion has helped you. Have a good
day!

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2224
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups of searchable fields in the fields 3. Each group can be expanded/collapsed by clicking on a link "(Fewer|More) Options" which sits right next to the group title.
2
1427
by: EventListener | last post by:
I have a folder/file tree that is dynamically generated from an xml file. The way I've written it seems to work. Since I'm a fairly novice javascript programmer, I'm concerned that there may be a hidden downside to coding this way vs. hiding/showing using style.visibility. My tree starts with only the top level folders showing. When the xml for the tree loads, I have a recursive function that creates subtrees for each folder, then saves...
1
3886
by: Dmitry Karneyev | last post by:
Hi! I've made a form with combobox and a tabcontrol. Each time the value of combobox changes I need to show only one tabpage from tabcontrol. It works, but the tabcontrol bookmark of selected tabpage is visible. I could be great if it's possible to hide it beacuse this element is useless in my case. Can anybody help me?
1
840
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems controlling the visibility of columns in the DataGrid control. The problem usually comes down to one fact. The DataGrid has a property called AutoGenerateColumns. The default value is "True". This means that when AutoGenerateColumns is set to True,...
2
1799
by: darrel | last post by:
I really like using Panels in ASP.net to show hide parts of a page. The only catch is that, by default, panels are rendered as DIVs. There are times when I'd like the panels rendered as Spans...so that they can be used as inline content. I can set the display: inline style programatically, or I can create a new CSS style for this panel and set the 'display: inline' style there, but I'm wondering if there's a more direct workaround that I...
2
1655
by: =?Utf-8?B?Sm9zaCBTY2htaWR0?= | last post by:
I have a gridview that is being used for managing inventory. The default view shows the stock currently available. When editing I don't want the stock to be directly edited, rather the user will enter the amount of items being added/removed. When the user clicks the 'Edit' link I want to hide the stock column and display a field for the TransactionAmt. I'm using the RowUpdating event to execute some functions used by that field. I've...
0
1009
by: =?Utf-8?B?QWxleA==?= | last post by:
I have 3 Update Panels on my page. On Page load, UpdatePanels 2 and 3 are hidden. When I click a button in UpdatePanel1, I display the other two UpdatePanels and their contents. UpdatePanel 2 has an server-side button that when clicked, it needs to reference controls in UpdatePanel3 and perform some functions on the server. Since UpdatePanel2 and 3 weren't included in the original page, clicking the button in UpdatePanel 2 doesn't do...
1
1382
by: Eric Hohnbaum | last post by:
The client would love their app to work just like Visual Studio with auto-hide panels, but that's not realistic. I am, however looking for ideas or samples on how to make the user able to show and hide a frame on demand. The app is currently using HTML frames and any solution that doesnt involve ripping them out is best. I'll condider other techniques but that would mean a higher price quote that might not get approved. Thanks.
17
2021
by: rohitchawla | last post by:
i am trying to show and hide a div when onmouseover and onmouseover another div element. i am setting a setTimeout duration on onmouseout to delay the hiding of div for around two second The problem is that when i mouseover an element and then onmouseout it and then back again mouseovers that element before the timeout, the element still gets hidden so i put a flag=1 when i mouseover the element and flag=0 at mouseout and checked the value...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10043
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.