We are adding the telerick dlls dynamcially through reflection dynamically at run time. We had the issue of loading the embeded resources in reflection . So, we disabled the telerick embeded resources and loadin it dynamically. Our user controls are not designed in ascx rather they are defined as webcontrols. The issue that i am facing is, i am able to add all the required resources dynamically to my customer control dll and while executing the telerick dll resrouces, say the Radbutton.js file, i am getting $(telerick) is undefined.
Please let me know is it possible to load the telerick resource files dynamically in webcontrols using scriptreferences, if so, what are the additional parameters that i need to add? Any help would be appreciated.
Please note that i have added all the required js / css files also.
Thanks,
My script reference method, passin the dll and the reousrce details,
public IEnumerable<ScriptReference> GetScriptReferences()
{
this.EnableEmbeddedScripts = false;
// ClientScriptResource("Telerik.Web.UI.RadButton", "Telerik.Web.UI.Button.RadButton.js"),
ScriptReference reference =
new ScriptReference();
reference.Name =
"Telerik.Web.UI.Button.RadButton.js";
reference.Assembly =
"Telerik.Web.UI, Version=2010.3.1215.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4";
string[] Names = reference.Assembly.Split(',');
string DLLName = Names[0].Replace("\\", "");
string VersionNumber = Names[1].Split('=')[1].Replace("\\", "");
string Culture = Names[2].Split('=')[1].Replace("\\", "");
string PublicKeyToken = Names[3].Split('=')[1].Replace("\\", "");
reference.Path =
"~/MyScriptHandler.ashx?Assembly=" + DLLName +
"&VersionNumber=" + VersionNumber +
"&Culture=" + Culture +
"&PublicKeyToken=" + PublicKeyToken +
"&ResourceName=" + reference.Name;
return new ScriptReference[] { reference };
}
My ashx code to load the resource file dynamically,
public void ProcessRequest(HttpContext context)
{
string DLLName = context.Request["Assembly"];
string VersionNumber = context.Request["VersionNumber"];
string Culture = context.Request["Culture"];
string PublicKeyToken = context.Request["PublicKeyToken"];
string ResourceName = context.Request["Resourcename"];
string TypeFQN = DLLName + ", Version=" + VersionNumber + ", Culture=" + Culture + ", PublicKeyToken=" + PublicKeyToken;
Assembly ResourcesAssembly = Assembly.Load(TypeFQN);
Stream IOFile = ResourcesAssembly.GetManifestResourceStream(ResourceName);
byte[] bytes = new byte[IOFile.Length];
IOFile.Read(bytes, 0, bytes.Length);
string contentType = getContentType(ResourceName);
if (contentType == "text/plain")
{
string outputfile = string.Empty;
if (HasUtf8ByteOrderMark(bytes))
{
outputfile =
Encoding.Default.GetString(bytes).Substring(3);
}
else
{
outputfile =
Encoding.Default.GetString(bytes);
}
context.Response.Write(outputfile);
}
else
{
context.Response.BinaryWrite(bytes);
}
}