Hi Experts,
I have a master page with body tag looks like this:
<body runat="server" id="pageBody">
I need to change the body background image according to user choice from dropdownlist.
So I called master page body tag in content page code behind (dropdownlist selectedIndexChanged) like the following:
HtmlGenericControl body = HtmlGenericControl)Master.FindControl("pageBody");
and then i did the following to change the background attribute:
body.Attributes["style"] = "background: url('img/ic-vehicles/" + year_reg.SelectedItem.Text + "-" + make_reg.SelectedItem.Text + "-" + model_reg.SelectedItem.Text + "-" + trim + ".jpg') center center no-repeat ;background-attachment: fixed;";</pre>
The background is not changing!
I made sure the path is correct using this code:
bool isexist = File.Exists(Server.MapPath("img/ic-vehicles/" + year_reg.SelectedItem.Text + "-" + make_reg.SelectedItem.Text + "-" + model_reg.SelectedItem.Text + "-" + trim + ".jpg"));
EDIT: forgot to say when I put break point i see this exception:
base {System.Web.UI.HtmlControls.HtmlContainerControl} = {InnerText = '((System.Web.UI.HtmlControls.HtmlContainerControl)(((System.Web.UI.HtmlControls.HtmlGenericControl)(body)))).InnerText' threw an exception of type 'System.Web.HttpException'}
Any suggestions?
Thank you