Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 :

JavaScript
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 :

VB
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
Updated 25-Dec-11 18:08pm
v3
Comments
Karthik Harve 26-Dec-11 0:04am    
[Edit] pre tags added.

1 solution

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.
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900