C# (.NET) Problem...

DeepakG

Perch
Any .NET Programmers here?

I am trying to use the following C# code to emit some javascript code. It works fine at home, but doesn't emit the javascript when used on Jodohost.

Code:
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

public class TreeView : Table, INamingContainer
{

/*
    The rest of the code was truncated.
*/
		protected override void OnPreRender(EventArgs e)
		{
			if (!Page.IsClientScriptBlockRegistered("ShowHideTable") && !Page.IsPostBack)
			{
				Page.RegisterClientScriptBlock("ShowHideTable", ShowHideTableScript());
			}			
		      
			base.OnPreRender (e);
		}

		public static string ShowHideTableScript()
		{
			const string script =
			@"<script language=""JavaScript"">
			   function ShowHideTable( targetId )
			   {		   	
					if (document.getElementById){
						target = document.getElementById( targetId );
						
						if (target.style.display == ""none""){
							target.style.display = """";
						}
						else {
							target.style.display = ""none"";
						}
					}
				}
			</script>
			";
			
			return script;
		}
}

Note: This class implements a web control by inheriting from System.Web.Ui.WebControls.Table. There are NO syntax or runtime errors. The code simply does not output the Javascript on Jodohost, but works on my local web server.
 
Back
Top