Passing variable from ascx.cs file to javascript written in ascx

Hey !

I have this Javascript snippet in my style_block.ascx file:

<script type="text/javascript">

    if (!window.slider) var slider = {};
 += "[";
        var i = 1;
        while (i < max_dot) {
   += "{\"id\": \"slide-img-" + i + "\", \"client\": \"\", \"desc\": \"\"},";
        } += "{\"id\": \"slide-img-" + i + "\", \"client\": \"\", \"desc\": \"\"}]";
Notice - Bold "max_dot variable

max_dot value is actually result of a sql query "Select count(*) from mantle" which I wrote in Style_block.ascx.cs

I am novice to Javascript, really a starter. Basically I want to access "max_dot" value between javascript tags. How can I do that ? Function ? Global variable ?


Who is Participating?
KelmenConnect With a Mentor Commented:
//server asp code
int ServerCode_MaxDot = myhelper.GetMaxDotValueFromWherever();

<script javascript>
var MaxDot = <%=ServerCode_MaxDot%>;
for (i < MaxDot ) ...
pratz09Author Commented:
Thanks Kelmen !
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.