Click here to Skip to main content
15,888,210 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
How to set javascript function when postback occured
Posted
Comments
Sridhar Patnayak 26-Dec-11 1:43am    
pls explain briefly
VenuKalyan 27-Dec-11 1:11am    
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 :

Collapse | Copy Code
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 :

Collapse | Copy Code
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..

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);

if any clarification then tell me.
 
Share this answer
 
Comments
VenuKalyan 26-Dec-11 2:38am    
Pls explain..iam using vb script..
VenuKalyan 26-Dec-11 2:39am    
pls explain

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