Click to See Complete Forum and Search --> : loading a javascript after every server request


livez
09-26-2005, 07:52 AM
Hello

I have a javascript that hides controls on a page depending on a few settings. At the moment I only call this script from the Page's Body_OnLoad event. The problem is I have a ASP:Button with autopostback = true, and when this is pushed all the controls that were hidden by the javascript suddenly appears. Where do I call the javascript to run it after every server request?

/Regards Magnus

livez
09-28-2005, 01:55 AM
Found a good solution, in case anyone else would get the same problem. This code will
hide a DIV depending on if an IF-statement is fullfilled.

private void btnKnapp_Click(object sender, System.EventArgs e)
{
if (divInsats is to be hidden)
{
StringBuilder JavaScript = new StringBuilder();
JavaScript.Append("<SCRIPT language='javaScript'>");
JavaScript.Append "document.getElementById 'divInsats')
.style.visibility = 'hidden';");
JavaScript.Append("</script>");
this.RegisterStartupScript("ClientScript",JavaScript.ToString());
}

}