views:

35

answers:

1

i just want to be able to call a javascritp subroutine on the client, after the server has done its thing (when an action completes or control goes to the view, i'd dont mind calling the js from the view either).

for some reason, even vs2010 doesn't let me put breakpoints in <% ... %> tagged areas between <script...> and </script> tagged areas. i for this reason can't figure out whats going on and how it's running things. here is what i've put in my view, and the javascritp should run, but it doesn't....

im just trying to call "RunOnceRoutines;" but it's not getting called!

the 2 questions: how on earth do we call javascript methods from server, and where is all this lovely javascript debugging i've heard about since vs2008? no where to be found!

    <%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of FP.RatePicModel)" %>



<script type="text/javascript" language="javascript">
        var RatePicPanelRunCount = 0;

        function ChangeMainPic(newSrc) {
        $get("imgPic").src = newSrc;
        alert($get("imgPic").src + '\n' + newSrc);
        RatePicPanelRunCount++;
        }


        function UpdateGlobalVariables() {
        // Update variables...
        ShownPicID = <%=Model.CurShownPicID%>;

            <% //this shows up!
             msgbox(model.curshownpicid)
             %>

        ShownUserID = <%= Model.CurShownUserID %>;
            CurrentUserID = <%= UserID %>;
            alert('CurUserID is ' + CurrentUserID);
            alert('From cookie its ' + getCookie('UserID'));
        }

        function RunOnceRoutines() {
        if (RatePicPanelRunCount == 0) {
                ChangeMainPic('<%= Model.CurPicURL%>');
                UpdateGlobalVariables;
        };
        }

        RunOnceRoutines;


</script>


<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td>
            <%
                Html.RenderPartial("AddToFavs", Model.AddFavAction)
            %>

        </td>
    </tr>
</table>
+1  A: 

Looks to me like you have syntax errors causing the js to break before it gets to that function invocation. Have you checked your debug output? The Firebug plugin for FireFox is great for this

Edit: To enable JS debugging in ie, you need to set it in the internet explorer options. Checkout out this link for details

MPritch
internet explorer doesn't return a javascript error, whats normally a yellow exclamation, doens't exist, so says javascript is fine and that there are no issues with it. what do you think about this?
Erx_VB.NExT.Coder
i checked the syntax again seems to be ok, unless you found a syntax error, but the browser says its ok as well. any ideas?
Erx_VB.NExT.Coder
Have you tried viewing the source and looking at the code rendered to the client? That will give you some more clues. My point about syntax errors is more down to there being several undeclared variables in your JS.
MPritch
those variables are declared further up the chain in the main master page, so exist in the same page. did look at the source, everything is output, just doesn't run the subroutines i'm trying to run.
Erx_VB.NExT.Coder