473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

show hide div portion.

hi, all
i have an asp.net web application.
there is a master page and content pages.
my startup page is default.aspx, which is a content page. i have a div portion in my default.aspx page.

Now i want to hide this div Portion when the Page_Load().

i have written a javascript, & call it in the

<Body onload="javascript:setVisibility('id','none') ">

, it works but, some time, it shows the div for 2-3 seconds & then hide it.
Expand|Select|Wrap|Line Numbers
  1. //javascript is:---------->
  2.  
  3. function setVisibility(id,visibility)
  4.     {
  5.      document.getElementById(id).style.display = visibility;
  6.     }
  7. //------------------------------>
what is the problem.

please help me.

thanx ,
neel
Dec 10 '08 #1
5 18170
nukefusion
221 Expert 100+
I must admit that I'm not massively knowledgeable on ASP.NET, so I could be wrong, but it makes sense in my own mind that if you register a Javascript function to run on the client on page load, that there might be a small delay between your page showing and the script executing - causing this flicker effect.

Could you not just set the visibility of the DIV in the code behind so that the processing takes place on the server before the page is renderered on the client?
Dec 10 '08 #2
baburmm
12
you can also hide the div tag inside the c# Code

just change your div tag like

<div id="div1" runat="server">
//something
</div>

in C# code set

div1.visible=false

may be it will helps you

Regards,
Babu.K
Dec 10 '08 #3
Frinavale
9,735 Expert Mod 8TB
Initially set the CSS for the to have a style="visiblity:hidden" and use the function to set the CSS to have a style="visibility:visible" once the page has loaded.

This will always hide the div when the page is first rendered and then show it only after the page has loaded.

You don't need to set the <Div> to run at server. Just simply put:

Expand|Select|Wrap|Line Numbers
  1. <div style="visibility:hidden;"></div>
If you do the above (make the <div> run at server and then use div.visible=false) the Div will not be rendered in the browser and your JavaScript will crash. There is a huge difference between setting the visibility using server side code and setting it using CSS.

In this case you want to use CSS.
Dec 10 '08 #4
Hi, Frinavale

Thanx, by changing the css of div , the problem looks to be solved.


thank u all, again.

neel
Dec 11 '08 #5
balabaster
797 Expert 512MB
@Frinavale
It might also be useful to note that the asp:panel can be used in place of div as it renders a div on the client side anyway. That way you've got access to all the control properties that the panel control implements. On the client side it's no different than if you had registered a div. That way you can do the same thing as you did with the div, but in a more declarative manner:

<asp:panel id="MyDiv" runat="server" visible="false"></asp:panel>
Dec 12 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Steve | last post by:
Visual Studio 2003 C# Windows: I have a tree view control as my main menu control down the left side of my application. This has 2 Parent Nodes on it (Jobs and Employees). beneath these 2 main...
10
by: oLE | last post by:
I would like to add some javascript to show/hide a certain row of a table. The first row of the table contain the hyperlink that calls the javascript the second row is the one i want to show/hide...
0
by: Efkas | last post by:
I have a full custom application with some widged extending Controls like Label and PictureBox. I build a menu with these widgets. When I click on one of them, it calls a function to display...
4
by: bridgemanusa | last post by:
Hi All: I have a very long page of html that I want to take portions and hide them in divs, then show when a link is clicked. I have the hide show part working when the link is clicked, however...
7
by: FP | last post by:
I'm new to Java Script. I'm displaying comments people have made. Below each persons' comment I want to add 2 buttons "Reply" and "Amend". Clicking "Reply" would display an empty text field...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
7
chunk1978
by: chunk1978 | last post by:
hello, i would like to know if it's possible to hide PHP values that come back empty (text fields) or have a specific value (select menus)... on my form, there are input fields that are...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.