Click here to Skip to main content
12,250,675 members (38,236 online)
Rate this:
 
Please Sign up or sign in to vote.
Hi to all,
I am Using Javascript Function for Hiding and showing a panel when user clicks a hyperlink..its working fine, but in postback event all panels automatically visible..
how to stop..it..

My Javascript Function :

function ShowHide(id) 
{
	try
        {
		var e = document.getElementById(id);
		if(e.style.display == 'block' || e.style.display=='')
			e.style.display = 'none';
		else
			e.style.display = 'block';
	}
	catch(e)
	{ 
		alert( "Error in JS Function: 1" + e); 
	}          
   }

My PageLoad event :

If Not IsPostBack Then
      AddAttributes()
 End If
 
Private Sub AddAttributes()
        Try
          Hplink.Attributes("onclick") = "ShowHide('Panel1');"
          Hplink.Attributes("onclick") = "ShowHide('Panel2');"
          Hplink.Attributes("onclick") = "ShowHide('Panel3');"
          Hplink.Attributes("onmouseover") = "this.style.cursor='pointer'"
          Hplink.Attributes("onmouseout") = "this.style.cursor='pointer'"
        Catch ex As Exception
 
        End Try
    End Sub
pls..give code for it..
Thanks..
Posted 25-Dec-11 18:01pm
Edited 25-Dec-11 18:08pm
v3
Comments
Karthik Harve 26-Dec-11 0:04am
   
[Edit] pre tags added.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Call javascript function showhide() after each successful event occured using

ScriptManager.RegisterStartupScript(this,this.GetType(), "%#######%", "ShowHide('Panel1');",true);

OR

this.ClientScript.RegisterStartupScript(this.GetType(), "%#######%", "ShowHide('Panel1');",true);

"ShowHide('Panel1');" it depends on you what you want to display. if any clarification then tell me.
  Permalink  
Comments
VenuKalyan 27-Dec-11 0:13am
   
it does't work..iam using vs2003 with vb.net

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 26 Dec 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100