mr.abuasbe Posted January 25, 2016 Share Posted January 25, 2016 (edited) 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 January 25, 2016 by mr.abuasbe Link to comment Share on other sites More sharing options...
justsomeguy Posted January 25, 2016 Share Posted January 25, 2016 Why use Javascript? Why not just use the server-side language to directly write that HTML into the page? Link to comment Share on other sites More sharing options...
mr.abuasbe Posted January 25, 2016 Author Share Posted January 25, 2016 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? Link to comment Share on other sites More sharing options...
justsomeguy Posted January 25, 2016 Share Posted January 25, 2016 You're already using "<%=" to write to the client. You can also use Response.Write. https://msdn.microsoft.com/en-us/library/1463ysyw(v=vs.110).aspx Link to comment Share on other sites More sharing options...
mr.abuasbe Posted January 26, 2016 Author Share Posted January 26, 2016 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>"; } Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now