There's absolutely no way to modify that jscript file before it gets
to the client, short of wrapping it in a generic handler, reading the
file, and writing it out while replacing chunks of code. I've found a
couple of ways around this. One would be to add a line in your OnLoad
event handler such as the following:
this.ClientScript.RegisterClientScriptBlock(this.GetType(),
"someuniquekey", string.Format("var temp =
document.getElementById('{0}');", this.ctrl.ClientId));
Another way (much cleaner way) would be to create a javascript class
using the asp.net ajax clientscript library. Here's a tutorial:
http://asp.net/ajax/documentation/live/tutorials/CreatingCustomClientScripts.aspx
Just a couple of options, none of them great =) Good luck!
hungrymind - 15 Mar 2008 20:13 GMT
thanks digital jee,
however i tried to initialize all c# property to javascript using
relection like this
Type type = this.GetType();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("var Map"+this.ID+" = new MyMap();");
foreach (PropertyInfo propertyInfo in
type.GetProperties())
{
if (propertyInfo.PropertyType == typeof(string))
{
stringBuilder.Append(" Map" + this.ID + "." +
propertyInfo.Name + " = '" + propertyInfo.GetValue(this, null) +
"';");
}
if (propertyInfo.PropertyType == typeof(double))
{
stringBuilder.Append(" Map" + this.ID + "." +
propertyInfo.Name + " = " + propertyInfo.GetValue(this, null) + ";");
}
}
return stringBuilder.ToString();
this has resolved my issue so far, but I wanted to keep JS & C#
absolutely seperate. I will look into second options, if it is not
only related with AJAX then it will work for me.
many thanks
hungrymind
www.hungrymind-concepts.com