"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:ut******************************@eclipse.net. uk...
John,
If you want to work just with the body tag then you could allocate a runat
server attribute to your body tag In the master page.
<body runat="server" id="masterBody">
in the Page_Load event of the container add something like:
HtmlGenericControl body = (HtmlGenericControl)
Page.Master.FindControl("masterBody");
body.Attributes.Add("style", "BACKGROUND-POSITION: center bottom;");
You would only need to add this to load events in containers that required
it. I've never tried it mind you, it might not work!!!
Thanks for this! Firstly, I can confirm that it does work... :-)
However, curiously, the line which instantiates the HtmlGenericControl
object generates an error which is not caught by the standard try..catch
handler. By which I mean that stepping through the code below I can see that
an error is raised, but this doesn't jump into the error handler, and
continues through the code.
The MasterPage body tag is as follows:
<body id="objBody" runat="server">
The Page_Load of the child page is as follows:
protected void Page_Load(object sender, EventArgs e)
{
try
{
HtmlGenericControl objBody =
(HtmlGenericControl)Master.FindControl("objBody");
objBody.Attributes.Add("style", "background-image:
url(../images/skylinelogo.gif);");
}
catch (Exception ex)
{
CApplication.GlobalExceptionHandler(ex);
}
}
The error is:
{InnerText =
'((System.Web.UI.HtmlControls.HtmlContainerControl )(objBody)).InnerText'
threw an exception of type 'System.Web.HttpException'}
base {System.Web.UI.HtmlControls.HtmlContainerControl}: {InnerText =
'((System.Web.UI.HtmlControls.HtmlContainerControl )(((System.Web.UI.HtmlControls.HtmlGenericControl) (objBody)))).InnerText'
threw an exception of type 'System.Web.HttpException'}
TagName: "body"
Now, can anyone please tell me:
1) What the error means?
2) Why it isn't caught by the try...catch handler?
3) Is it safe to ignore it, since the code proceeds past it and does what
it's supposed to do?
Any assistance gratefully received.
Mark