How to: Artisteer + Asp Net + Random Flash Banner Header |
|
alvin
|
well i need a random banner, how to:
1.- Edit the DefaultHeader.ascx file and remove the follow lines :
< div class=""art-Logo"
< h1 id=""name-text"" class=""art-Logo-name""><a href=""#"">Operadora</a></h1>
< div id=""slogan-text"" class=""art-Logo-text""></div>
</div>"
we generate this lines via code :D
2.- Now open DefaultHeader.ascx.cs
and now override the render method:
protected override void Render(HtmlTextWriter writer)
{
DirectoryInfo DirInfo = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/banners/"));
// Count No Banners in Directory
int NoBanners = DirInfo.GetFiles("*.swf").Length;
Random Aleatorio = new Random();
string SourceFileName =FixupUrl("~/banners/banner" + String.Format("{0:00}", Aleatorio.Next(1, NoBanners + 1)) + ".swf");
writer.Write(@"<div class=""art-Logo""> ");
writer.Write(@" <h1 id=""name-text"" class=""art-Logo-name""><a href=""#"">Operadora</a></h1> ");
writer.Write(@" <div id=""slogan-text"" class=""art-Logo-text""></div> ");
writer.Write(@"</div>");
writer.Write("<div>");
// utilize the style elemnt to place the banner in a absolute position in header!!!
writer.Write(@"<object style=""position:absolute; top:0px; left:292px;"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0""" );
writer.Write(@" width=""700"" height=""110""> ");
writer.Write(@"<param name=""movie"" value=""" + SourceFileName + @""" />");
writer.Write(@"<param name=""quality"" value=""high"" /> ");
writer.Write(@"<embed src=""" + SourceFileName + @""" quality=""high"" ");
writer.Write(@"pluginspage=""http://get.adobe.com/flashplayer/"" type=""application/x-shockwave-flash"" ");
writer.Write(@"width=""700px"" height=""100px""></embed> ");
writer.Write(@"</object>");
writer.Write(@"</div>");
base.Render(writer);
}
3.- Resolve relative path with:
public string FixupUrl(string Url)
{
if (Url.StartsWith("~"))
return (HttpContext.Current.Request.ApplicationPath +
Url.Substring(1)).Replace("//", "/");
return Url;
}
4.- Now get a beer, drink, and Salud!!!
Saludos from mexico.
|
|
Artisteer
|
Alvin,
Great tips!
|
|
Alvin
|
Update :
This tipo works with all Browsers but in IExplorer not:
well i wanna this work.
Well we use a hack to make this work:
Replace 2 lines:
writer.Write(@"<div id=""Fija"" > ");
writer.Write(@"<object codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,124,0""");
LIne 1: we use a css # in div element
Line 2: remove the style=""position:absolute; top:0px; left:292px;""
Now in style.css
add #Fija css
#Fija {
position:absolute;
top:0px;
left:292px;
}
wow now the random banner work with IE.
|
|
ramzi
|
the files defaultheader.ascx and the one .ascx.cs are empty except a couple of lines.
they don't contain < div class=""art-Logo"
< h1 id=""name-text"" class=""art-Logo-name""><a href=""#"">Operadora</a></h1>
< div id=""slogan-text"" class=""art-Logo-text""></div>
</div>"
|
|
|
|