mr.abuasbe

duplicated code | help

5 posts in this topic

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

Thats it, i want to make it from server side, but i didn't really know how should i make it to write to the client side.

I need to replace document.write with?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now