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

Discussion in 'ASP .Net' started by Chris Auer, Oct 16, 2007.

  1. Chris Auer

    Chris Auer Guest

    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
    Chris Auer, Oct 16, 2007
    #1
    1. Advertising

  2. Chris Auer

    Chris Auer Guest

    On Oct 16, 12:05 pm, Chris Auer <> wrote:
    > 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.
    Chris Auer, Oct 16, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Afigels
    Replies:
    0
    Views:
    558
    Afigels
    Nov 16, 2004
  2. Jeremy Chapman

    GetWebResourceUrl and dynamic resources

    Jeremy Chapman, Apr 29, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    3,559
    Jeremy Chapman
    May 1, 2006
  3. cruster

    GetWebResourceUrl and MasterPage

    cruster, Feb 14, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    473
    cruster
    Feb 14, 2007
  4. Replies:
    2
    Views:
    807
  5. Randell D.
    Replies:
    12
    Views:
    253
    Randell D.
    Jul 6, 2005
Loading...

Share This Page