The project is called "EmbeddedResour ces" with the namespace "EmbeddedResour ces"
My resources are not included when the content is rendered in the browser.
I have marked my JavaScript resource as Embedded. I am able to retrieve the path to the resource from the WebResource.axd HTTP Handler during run time; however that resource can never be found by the browser during run time.
I have an embedded JavaScript file named "ChangeTextboxB g.js" located in the root directory of my project with the following contents:
Expand|Select|Wrap|Line Numbers
- function ChangeBackgroundColor(ctrl)
- {
- ctrl.style.backgroundColor = "#C00000";
- }
Expand|Select|Wrap|Line Numbers
- <%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Master.Master" CodeBehind="Index.aspx.vb" Inherits="EmbeddedResources.Index"
- title="Untitled Page" %>
- <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
- </asp:Content>
- <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
- <asp:TextBox ID="CrazyTextBox" runat="server"></asp:TextBox>
- </asp:Content>
Expand|Select|Wrap|Line Numbers
- Partial Public Class Index
- Inherits System.Web.UI.Page
- Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- End Sub
- Private Sub Index_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
- Dim pathToResource As String = Page.ClientScript.GetWebResourceUrl(Me.GetType, "EmbeddedResources.ChangeTextboxBg.js")
- Page.ClientScript.RegisterClientScriptInclude("testResource", pathToResource)
- 'ScriptManager.RegisterClientScriptInclude(Me, Me.GetType, "testing", ResolveClientUrl(pathToResource))
- CrazyTextBox.Attributes.Add("onkeypress", "ChangeBackgroundColor(this);")
- End Sub
- End Class
Expand|Select|Wrap|Line Numbers
- <%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Master.master.vb" Inherits="EmbeddedResources.Master" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" >
- <head runat="server">
- <title>Untitled Page</title>
- <asp:ContentPlaceHolder ID="head" runat="server">
- </asp:ContentPlaceHolder>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <asp:ScriptManager ID="ScriptManager1" runat="server" />
- <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
- </asp:ContentPlaceHolder>
- </div>
- </form>
- </body>
- </html>
Expand|Select|Wrap|Line Numbers
- <Assembly: WebResource("EmbeddedResources.ChangeTextboxBg.js", "text/javascript")>
As you can see I attempted using the ScriptManager to include the resource to the page, but this made no difference.
I've also attempted change the properties on the "ChangeTextboxB g.js" embedded file so that it copies itself to the output directory...but this also made no difference.
I am completely baffled as to why this doesn't work.
If anyone has any idea of what the problem may be I'd be happy to hear your thoughts!
Thanks a lot
-Frinny