I have a child Login.aspx with Master page "Site.Master". I want that every time, user comes on Login page, then different images should be shown.
In my Login.aspx :
<%@ MasterType VirtualPath="~/Site.Master" %>
<%@ Register Src="~/Account/OpenAuthProviders.ascx" TagPrefix="uc" TagName="OpenAuthProviders" %>
In Code-Behind :
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetAllBackgroundImages();
}
if (bgfiles != null)
{
Random r = new Random();
int index = r.Next(bgfiles.Length);
string imgFile = bgfiles[index];
this.Master.ContentBackground = imgFile;
}
In site.Master :
site.Master code Behind :
public string ContentBackground
{
get
{
return "";
}
set
{
masterContent.Style.Add("background-image", "url('" + value + "')");
}
}
With the above code, the images are collected in GetAllBackgroundImages();, a image is also selected and this.Master.ContentBackground = imgFile; is also called, but their is no image seen on the Login page.
Any idea where am I going wrong ?? Any help is highly appreciated.
Thanks
4 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
ramya bharathPosted May 6, 2015, 8:03 PM
Your file path need nit be in quotes refer this https://msdn.microsoft.com/en-us/library/ms530717(v=vs.85).aspx hooe it solves ur issue
TerryPosted May 7, 2015, 1:36 AM
Along with the quotes, the other problem was of Path. The path was sending as "\CRMImages\BGImages\Filename.jpg". I just picked up the file name & set the path as "/CRMImages/BGImages/Filename.jpg" - changed the slash and it worked.
Thanks a lot.
TerryPosted May 6, 2015, 3:51 PM
In the source of the browser, I saw the style reflecting in the masterContent div as follows :
ramya bharathPosted May 6, 2015, 1:38 PM