Jump to content
mr.abuasbe

duplicated code | help

Recommended Posts

hi,
i have this key on the client side (asp.net)

    function newContent()
     {
         var a = <%=rowCounter%>;
         for (i = 0; i < a; i++) {               
    
         document.write('<div class="col-sm-6 col-md-4">');
         document.write('<div class="thumbnail">');
         document.write('<img src="<%= array[0,2]%>" alt="..."/>');
         document.write('<div class="caption">');
         document.write('<h3 class="d-text"><%= array[0,1]%></h3>');
         document.write('<p class="d-text"><%= array[0,3]%></p>');

         document.write('</div>');
         document.write('</div>');
         document.write('</div>');    
         }
     }

but to make the loop work with the variables i need to move the code to server side,
so how can i use document.write() on the server side ?

thanks a lot

Edited by mr.abuasbe

Share this post


Link to post
Share on other sites

Why use Javascript? Why not just use the server-side language to directly write that HTML into the page?

Share this post


Link to post
Share on other sites

thanks for your help ..

now response didn't work for me ..

i used this way :
i created div (rowdg) and wrote in the div from the server side

        for (int i = 0; i < rowCounter; i++) {  
        rowdg.InnerHtml += "<div class="+'"'+ "col-sm-6 col-md-4" +'"'+ ">";
        rowdg.InnerHtml += "<div class=" + '"' + "thumbnail" + '"'+ "style="+'"'+ "height:400px" + '"'+  ">";
        rowdg.InnerHtml += "<img src=" + '"' + array[i, 2] + '"' + "height="+'"'+"225"+'"'+"width="+'"'+ "225" +'"' + "/>";
        rowdg.InnerHtml += "<div class=" + '"' + "caption" + '"' + ">";
        rowdg.InnerHtml += "<h3 class=" + '"' + "d-text" + '"' + ">" + array[i, 1] + "</h3>";
        rowdg.InnerHtml += "<p class=" + '"' + "d-text" + '"' + ">" + array[i, 3] + "</p>";
        rowdg.InnerHtml += "<p class=" + '"' + "=text-center" + '"' + "><a href = " + '"' + array[i;
        rowdg.InnerHtml += "</div>";
        rowdg.InnerHtml += "</div>";
        rowdg.InnerHtml += "</div>";   
        }

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...