This is a migrated thread and some comments may be shown as answers.

To Support telerick controls for Multi versioning

1 Answer 89 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jayakumari
Top achievements
Rank 1
Jayakumari asked on 06 Feb 2012, 05:19 PM
Hi there,
   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);

}

}


1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 08 Feb 2012, 03:32 PM
Hello,

When you are using the controls with disabled embedded resources, you need to make sure you are loading all the necessary files. They are listed in the below article:
http://www.telerik.com/help/aspnet-ajax/introduction-disabling-embedded-resources.html
Having the above in mind, to have a fully functional RadButton, you need to load Core.js, jQuery.js, jQueryPlugins.js before the RadButton.js script file.

Kind regards,
Iana Tsolova
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
General Discussions
Asked by
Jayakumari
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or