Hi,
I have a master page & various pages that will use this master page. Each content page will have a CSS & JS file which will be named the same as the content page.
When I try to load the CSS & JS files using the code behind of the content page, my buttons aren't rendered and Im not sure why?
Here is the code for my content page - Properties.aspx :- - <%@ Page Language="C#" AutoEventWireup="true" Title="Properties" CodeFile="Properties.aspx.cs" Inherits="Properties" MasterPageFile="~/MasterPage.master"%>
-
-
<asp:Content ID="_propertiesContent" ContentPlaceHolderID="_mainContentHolder" runat="Server">
-
<asp:Label ID="_test" Text="This is the main content panel holder" runat="server" />
-
<br />
-
</asp:Content>
-
-
<asp:Content ID="_buttonContent" ContentPlaceHolderID="_buttonContentHolder" runat="server" >
-
<asp:Button ID="Button1" runat="server" Text="Save" CssClass="button" />
-
<asp:Button ID="Button2" runat="server" Text="Undo" CssClass="button" />
-
<br />
-
</asp:Content>
-
-
<asp:Content ID="_validationContent" ContentPlaceHolderID="_validationContentHolder" runat="server">
-
<asp:ValidationSummary ID="validationSummary" ValidationGroup="ValidationGroup" runat="Server" />
-
</asp:Content>
Here is the code behind for Properties.aspx .cs:- - using ASP;
-
using System;
-
using System.Data;
-
using System.Configuration;
-
using System.Collections;
-
using System.Web;
-
using System.Web.Security;
-
using System.Web.UI;
-
using System.Web.UI.WebControls;
-
using System.Web.UI.WebControls.WebParts;
-
using System.Web.UI.HtmlControls;
-
-
public partial class Properties : Page
-
{
-
private string _pageName;
-
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
_pageName = Page.GetType().Name.Substring(0, Page.GetType().Name.IndexOf("_"));
-
-
if (!IsPostBack)
-
{
-
LoadStyleSheets();
-
LoadJavascriptFile();
-
}
-
}
-
-
private void LoadStyleSheets()
-
{
-
HtmlLink link = new HtmlLink();
-
link.Href = string.Format("~/{0}.css", _pageName);
-
link.Attributes["text"] = "text/css";
-
link.Attributes["rel"] = "stylesheet";
-
this.Header.Controls.Add(link);
-
}
-
-
private void LoadJavascriptFile()
-
{
-
HtmlGenericControl javaScriptLink = new HtmlGenericControl();
-
javaScriptLink.TagName = "script";
-
javaScriptLink.Attributes.Add("type", "javascript");
-
javaScriptLink.Attributes.Add("src", string.Format("JS/{0}.js", _pageName));
-
}
-
}
My Master Page code is:- - <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" Debug="true"%>
-
-
<!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 id="Head1" runat="server">
-
<title>Master Page</title>
-
</head>
-
-
-
<body>
-
<form id="MainForm" runat="server">
-
-
<!-- This bit in here needs to be configurable per page, main content section -->
-
<asp:ContentPlaceHolder ID="_mainContentHolder" runat="server" />
-
-
<!-- This bit in here needs to be configurable per page, button section -->
-
<asp:ContentPlaceHolder ID="_buttonContentHolder" runat="server" />
-
-
<!-- This bit is for the validation summary for each page -->
-
<asp:ContentPlaceHolder id="_validationContentHolder" runat="server" />
-
-
-
</form>
-
</body>
-
-
</html>
If I comment out the methods to Load CSS file & Load JS files in my properties page - then my label text & my buttons are rendered, but if I leave these methods in, then only my Label text renders - Any ideas why?
Many thanks
Janet
0 2743 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Rob Meade |
last post by:
Hi all,
I have just put together our organisations 'template' for our web
applications and have created 7 .ascx files which when dropped into my
template file work perfectly...however, I have a question...
As our team develops several applications I wanted these generic .ascx's to
be able to be used by all - therefore I've placed them in the root of the
domain we work on in a directory called /WebUserControls
|
by: Brian |
last post by:
I've looked through the previous posts on this one and have verified
permissions and location of my Dlls, but I am still getting an
exception when I try to Load an assembly.
The directory where my Dlls are located give the ASPNET user full
control, and all Dlls used by the Assembly in question are in the
local folder with the rest of the web application Dlls.
Could someone take a look at my error and shed some light on this?
|
by: Paul |
last post by:
Hi still testing the idea of using html files for forms and then integrating
this into a net app. I tried a small form with a button but noticed all I
could do with the button is to right click and select run at server. This
still does not seem the same as using a button from the .net tool box. Just
wondering why, thanks.
--
Paul G
Software engineer.
|
by: Alan Silver |
last post by:
Hello,
In classic ASP, I used to use two include files on each page, one before
and one after the main content, to provide a consistent layout across a
web site. That way I could just change the include files to change the
layout. When I came to ASP.NET, I used user controls to do a similar
thing.
I have just been looking at master pages, and it looks like they do the
same thing. If so, is there any advantage in using them over the...
|
by: Fred Nelson |
last post by:
Hi:
I'm working on one of my first web applications in asp.net 2.0 and I'm
having a problem with absolute versus relative positioning of controls
that I place on pages that use master pages with Content Place Holders.
The controls placed in a content area with absolute or relative
positioning can easily "drift" beyond my Content Place Holder.
I'm trying to put a "footer" on every page of the site and this is
| |
by: Rob R. Ainscough |
last post by:
I'm using forms authentication along with Master pages -- my authenticated
forms reside is a sub-dir (Secure) below the web site root dir. The problem
is that any graphics placed on the Master page do NOT appear in any of the
web forms located in my Secure dir, however, any forms off the root of my
web app will display the master page with the graphics.
Is there some trick to get master pages to work with forms authentication of
forms...
|
by: Arpan |
last post by:
When a Button is clicked in a Web Form in an ASPX page, the Form will
post back to itself. Under such circumstances (i.e. when a Button is
clicked), will the Page_Load sub execute first & then will the Click
event function of the Button execute or will the Click event function
of the Button execute first & then will the Page_Load sub execute?
Thanks,
Arpan
|
by: Homer J. Simpson |
last post by:
Hi all,
I have enough experience with HTML/classic ASP to get by, and I'm trying to
learn ASP.NET.
Traditionally, I've taken the habit of breaking out extra-long CSS files
into multiple, smaller ones, and referring to them in my HTML/ASP files on
an as-needed basis. Essentially, I've organized things as:
/default.asp
|
by: nukefusion |
last post by:
Hi all,
I'm trying to think of the best way to achieve a certain goal and thought I would draw on the experience here.
What I am currently doing is compiling a set of HTML files that form the help guide of an application I am working on.
The help guide needs to be integrated into both a C# .NET desktop app AND a .NET based website using master pages.
The requirements are that:
(a) The same set of files are to be accessible through...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |