In the Default.aspx.cs file of your example project, change this.GetType()
to typeof(_Default)
:
Page.ClientScript.RegisterClientScriptInclude("JScript1",
Page.ClientScript.GetWebResourceUrl(typeof(_Default), "EmbeddedResources.JScript1.js"));
Similarly, in the PaymentHistory.ascx.cs file, change this.GetType()
to typeof(PaymentHistory)
:
image1.ImageUrl = Page.ClientScript.GetWebResourceUrl(
typeof(PaymentHistory), "TestWebApp.Resources.Images.loading.gif");
Explanation: GetWebResourceUrl
looks at the type
argument to determine which assembly contains the embedded resource. Specifying this.GetType()
as the type
is incorrect because, in an .aspx or .ascx code-behind class, this.GetType()
refers not to that class but rather to the derived class that gets dynamically generated from the .aspx or .ascx markup. This derived class resides in a separate assembly, so GetWebResourceUrl
can't find the embedded resource.