///For Write the text file
public void makebannerForUI()
{
//for UI
string fileLoc = ConfigurationManager.AppSettings["BrandScrollFile"] + "BrandScroller.txt";
BenrosslinqDataContext bndb = new BenrosslinqDataContext();
var brand = from brands in bndb.tblBrandsLogos where brands.IsActive == true orderby brands.BrandName ascending select brands;
StringBuilder sb = new StringBuilder();
int i = 0;
foreach (var brn in brand)
{
i = i + 1;
sb.AppendLine("<li class='scrolimg' style='valign:veritcal-align:middle; text-align:center;vertical-align:middle' >" + "<a href=" + ImagePath + "Brands/" + brn.LogoId + "/" + clsComman.StringReplace(Convert.ToString(brn.BrandName)) + "> <img align=absmiddle src=" + ImagePath + "admin/BrandImages/" + brn.LogoImage + " alt=item " + i.ToString() + "/></a></li><li style='width:10px;text-align:center;'></li>");
}
FileStream fs = new FileStream(fileLoc, FileMode.OpenOrCreate);
StreamWriter sw = new StreamWriter(fs);
sw.Write(sb.ToString());
sw.Close();
} ///For Read and display the text file
public void getbrand()
{
if (Cache["brand"] == null && Convert.ToString(Cache["brand"]) == "")
{
using (StreamReader sr = new StreamReader(ConfigurationManager.AppSettings["BrandScrollFile"] + "BrandScroller.txt"))
{
ltbrand.Text = sr.ReadToEnd();
Cache.Insert("brand", ltbrand.Text, new System.Web.Caching.CacheDependency(ConfigurationManager.AppSettings["BrandScrollFile"] + "BrandScroller.txt"));
}
}
else
{
ltbrand.Text = Convert.ToString(Cache["brand"]);
}
}
No comments:
Post a Comment