I am attempting to use embedded resources in an Ajax Enabled ASP.NET Web Application. I'm using Visual Studio 2008 and VB.NET server side code.
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:
[code=javascript]
function ChangeBackgroun dColor(ctrl)
{
ctrl.style.back groundColor = "#C00000";
}
[/code]
I have an ASPX page named "Index.aspx " with the following contents:
[code=asp]
<%@ Page Language="vb" AutoEventWireup ="false" MasterPageFile= "~/Master.Master" CodeBehind="Ind ex.aspx.vb" Inherits="Embed dedResources.In dex"
title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHol derID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHol derID="ContentP laceHolder1" runat="server">
<asp:TextBox ID="CrazyTextBo x" runat="server"> </asp:TextBox>
</asp:Content>
[/code]
The VB.NET Server Side code (code behind) for this page is as follows:
[code=vbnet]
Partial Public Class Index
Inherits System.Web.UI.P age
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
End Sub
Private Sub Index_PreRender (ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.PreRender
Dim pathToResource As String = Page.ClientScri pt.GetWebResour ceUrl(Me.GetTyp e, "EmbeddedResour ces.ChangeTextb oxBg.js")
Page.ClientScri pt.RegisterClie ntScriptInclude ("testResource" , pathToResource)
'ScriptManager. RegisterClientS criptInclude(Me , Me.GetType, "testing", ResolveClientUr l(pathToResourc e))
CrazyTextBox.At tributes.Add("o nkeypress", "ChangeBackgrou ndColor(this);" )
End Sub
End Class
[/code]
And I have a Master page named Master.Master which contains the ScriptManager for the site:
[code=asp]
<%@ Master Language="VB" AutoEventWireup ="false" CodeBehind="Mas ter.master.vb" Inherits="Embed dedResources.Ma ster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<asp:ContentPla ceHolder ID="head" runat="server">
</asp:ContentPlac eHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptMana ger ID="ScriptManag er1" runat="server" />
<asp:ContentPla ceHolder ID="ContentPlac eHolder1" runat="server">
</asp:ContentPlac eHolder>
</div>
</form>
</body>
</html>
[/code]
I have marked the embedded resource (changeTextboxB g.js) as being accessible through the WebResource.axd HTTP Handler by adding the following line to my AssemblyInfo.vb
[code=vbnet]
<Assembly: WebResource("Em beddedResources .ChangeTextboxB g.js", "text/javascript")> [/code]
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
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:
[code=javascript]
function ChangeBackgroun dColor(ctrl)
{
ctrl.style.back groundColor = "#C00000";
}
[/code]
I have an ASPX page named "Index.aspx " with the following contents:
[code=asp]
<%@ Page Language="vb" AutoEventWireup ="false" MasterPageFile= "~/Master.Master" CodeBehind="Ind ex.aspx.vb" Inherits="Embed dedResources.In dex"
title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHol derID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHol derID="ContentP laceHolder1" runat="server">
<asp:TextBox ID="CrazyTextBo x" runat="server"> </asp:TextBox>
</asp:Content>
[/code]
The VB.NET Server Side code (code behind) for this page is as follows:
[code=vbnet]
Partial Public Class Index
Inherits System.Web.UI.P age
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
End Sub
Private Sub Index_PreRender (ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.PreRender
Dim pathToResource As String = Page.ClientScri pt.GetWebResour ceUrl(Me.GetTyp e, "EmbeddedResour ces.ChangeTextb oxBg.js")
Page.ClientScri pt.RegisterClie ntScriptInclude ("testResource" , pathToResource)
'ScriptManager. RegisterClientS criptInclude(Me , Me.GetType, "testing", ResolveClientUr l(pathToResourc e))
CrazyTextBox.At tributes.Add("o nkeypress", "ChangeBackgrou ndColor(this);" )
End Sub
End Class
[/code]
And I have a Master page named Master.Master which contains the ScriptManager for the site:
[code=asp]
<%@ Master Language="VB" AutoEventWireup ="false" CodeBehind="Mas ter.master.vb" Inherits="Embed dedResources.Ma ster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitl ed Page</title>
<asp:ContentPla ceHolder ID="head" runat="server">
</asp:ContentPlac eHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptMana ger ID="ScriptManag er1" runat="server" />
<asp:ContentPla ceHolder ID="ContentPlac eHolder1" runat="server">
</asp:ContentPlac eHolder>
</div>
</form>
</body>
</html>
[/code]
I have marked the embedded resource (changeTextboxB g.js) as being accessible through the WebResource.axd HTTP Handler by adding the following line to my AssemblyInfo.vb
[code=vbnet]
<Assembly: WebResource("Em beddedResources .ChangeTextboxB g.js", "text/javascript")> [/code]
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
Comment