Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
my friends there is blasten-turn jquery pluging but it has only 6 div tag 6 images include.

XML
<div id="magazine">
    <div style="background-image:url(pages/01.jpg);"></div>
    <div style="background-image:url(pages/02.jpg);"></div>
    <div style="background-image:url(pages/03.jpg);"></div>
    <div style="background-image:url(pages/04.jpg);"></div>
    <div style="background-image:url(pages/05.jpg);"></div>
    <div style="background-image:url(pages/06.jpg);"></div>
</div>


but ı have 100 images ı dont want to put 100 div tag lines
how to do c# code or any alternative method

how to put 100 div tag with c# code dynamically

ı want to do like this

XML
foreach (DataRow anaKategori in anaKategoriler)
           {

               HtmlGenericControl li = new HtmlGenericControl("li");
               //<li><a href="#" rel="p1"><img src="images/1.gif" width="206" height="95" alt="#"/></a></li>
               li.Controls.Add(new LiteralControl("<a href='ayrinti.aspx')%>" + "<img src='jcarousel/images/1.gif' width='206' height='95' alt='#'/>" + "</a>"));

               carousel.Controls.Add(li);

              

           }
Posted
Updated 7-Apr-12 12:58pm
v6

1 solution

Hi ,
Try this will guide you .

ASP.NET
<pre lang="xml"><div id="magazine" runat="server">

</div>


Code Behind :
C#
protected void Page_Load(object sender, EventArgs e)
    {
        //put how many times you want to loop 
        //note i  = 1 
        for (int i = 1; i < 5; i++)
        {
            HtmlGenericControl CreateDiv = new HtmlGenericControl();
          //this is for div but it wasn't work fine so i suggest use img 

            //CreateDiv.Style.Add(HtmlTextWriterStyle.BackgroundImage, "./images/"+ i+".jpg");
           // CreateDiv.InnerText = "regrgeagaegaregargagargaregaerg";
           // CreateDiv.Style.Add(HtmlTextWriterStyle.Width, "400");
           // CreateDiv.Style.Add(HtmlTextWriterStyle.Height, "400");          
               HtmlImage imgt = new HtmlImage();
               imgt.Src = "./images/"+ i+".jpg";
            CreateDiv.Controls.Add(imgt);

                magazine.Controls.Add(CreateDiv);
        }
    }

Best Regards
M.Mitwalli
 
Share this answer
 
Comments
Member-2338430 8-Apr-12 12:50pm    
thank you very much this method working
Mohamed Mitwalli 8-Apr-12 13:27pm    
your welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900