GetWebResourceUrl only working on one page, but no others. Assign the type and it works.

C

Chris Auer

I have one page that gets its contents from a class called
FormBuilder.cs. It generates a web part. On that page
GetWebResourceUrl works fine. All other pages generates an invalid
assembly key. If I change the type to the working class I can make it
work on any page.

Works
string scriptLocation =
Page.ClientScript.GetWebResourceUrl(typeof(FormsBuilderWebPart.FormBuilder),
"FormsBuilderWebPart.JScript1.js");
Page.ClientScript.RegisterClientScriptInclude("FormsBuilderWebPart.JScript1.js",
scriptLocation);


Does not Work
string scriptLocation = Page.ClientScript.GetWebResourceUrl(type,
"FormsBuilderWebPart.JScript1.js");
Page.ClientScript.RegisterClientScriptInclude("FormsBuilderWebPart.JScript1.js",
scriptLocation);

Any idea why the pages and controls keys are not working?

Thanks all
Chris
 
C

Chris Auer

I have one page that gets its contents from a class called
FormBuilder.cs. It generates a web part. On that page
GetWebResourceUrl works fine. All other pages generates an invalid
assembly key. If I change the type to the working class I can make it
work on any page.

Works
string scriptLocation =
Page.ClientScript.GetWebResourceUrl(typeof(FormsBuilderWebPart.FormBuilder)­,
"FormsBuilderWebPart.JScript1.js");
Page.ClientScript.RegisterClientScriptInclude("FormsBuilderWebPart.JScript1­.js",
scriptLocation);

Does not Work
string scriptLocation = Page.ClientScript.GetWebResourceUrl(type,
"FormsBuilderWebPart.JScript1.js");
Page.ClientScript.RegisterClientScriptInclude("FormsBuilderWebPart.JScript1­.js",
scriptLocation);

Any idea why the pages and controls keys are not working?

Thanks all
Chris

I found that you cant use this,GetType in a web application, only
classes. You have to do typeof(MyNameSpace.Class) to get the correct
assembly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top