used the following code to get rid of the system generated ID:-
Banner.ascx.cs
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
StringWriter Html = new StringWriter();
HtmlTextWriter Render = new HtmlTextWriter(Html);
base.Render(Render);
writer.Write(Html.ToString().Replace("id=\"ctl00_ContentPlaceHolder2_ctl00_Banner_", "id=\""));
}
using the above code its rendering the ID as the original one (ie "div1"..earlier it would render the div's ID as "ctl00_ContentPlaceHolder2_ctl00_Banner_div1"...so I thot changed ID is the reson its not displaying my image) only but still the image won't display...
testClass.aspx :-
<div id="div1" class="id0" style="background-image: url(<%=GetImage()%>);">
<ul>
<li>
<li>
.
.
.
</ul>
</div>
testClass.aspx.cs
public partial class testClass : System.Web.UI.Page
{
Control userControlBanner;
UserControl Banner;
Content c1;
protected void Page_PreInit(object sender, EventArgs e)
{
this.MasterPageFile = (String)("~/master1.master");
c1 = new Content();
string uc = "~/usercontrols/Banner.ascx";
userControlBanner = Page.LoadControl(uc);
userControlBanner.ID = "Banner";
c1.Controls.Add(userControlBanner);
this.Master.FindControl("ContentPlaceHolder2").Controls.Add(c1);
}
}
Now when the code above is rendered in the page source I see the complete image path as "http://localhost/myweb/images/myImage.jpg" and I can see the image when I type this address 'http://localhost/myweb/images/myImage.jpg" in browser why wont the image appear on my aspx page !? :((
I tried so hard to get rid of the system generated ID and still the image wont display! :((
Edit1:
ok I even gave the path(where the image actually is) of the image as this :- "F:\WS\myweb\images\myimage.jpg" ...it should at least show now!.. isn't it? Is the image getting hidden behind some other page element or what?
god I am stuck at this like anything :((
Edit2:
ok I tried what mxmissile said..added one div tag on my test page and assigned user control to that instead of "ContentPlaceHolder" (though I want the banner there only) ... now the image's still not appearing..everything else's fine..the list elements and all..just that image is not appearing...I removed everything from the usercontrol but the sprite image thinking may be the image's getting hidden or something behind that List of links..still no image :( somebody help please. Thanks!
Edit3:
When I opened Firebug..under "Style" section ...its showing the image path striked out..why is that ???
Edit4:
found out style was overridden..I gave background image in my css and same in the div tag with ID=id0..removed the background-image property from div tag..now image path's only in css...so no more striked out text..still the image's not appearing....path of the image's correct...in "Style" section in firebug..I can see the image when I hover over
.id0, .mySprite:hover div {
background-image:url("http://localhost/myWeb/images/myImage.jpg");
Why don't I see the banner image on my page?
Edit5:
changed this:
.id0, .mySprite:hover div
{
background-image: url(../images/myImage.jpg);
background-repeat: no-repeat;
}
to this:
.id0, .mySprite:hover div
{
background-image: url(../images/myImage.jpg);
background-repeat: no-repeat;
width: 728px;
height: 243px;
}
still nothing ! :((( If it's not even size issue, what is it ???
Edit6:
Image's being fetched now from a method... url(<%=GetImage()%>);
this method's returning the path alright..just don't see no image on my page ..what's wrong ??
[EDIT 7]
Its only after adding master page that this Sprite got screwed up..was working great earlier..