Different behaviour for hardcoded scripts and saved in a file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gfergadis
    New Member
    • Mar 2008
    • 1

    Different behaviour for hardcoded scripts and saved in a file

    Hello,
    I have a couple problems which I think they need attention from someone a bit more experienced in web developpement than I am.
    I want to change the text of an ASP:Label (Server Side), every time the user hovers the mouse on a client-side object.
    I manage to make that work with the script I attach below, however the problems raise when I try to make my code a bit more efficient.
    Ideally, I'd like to parse the "S" variable to the server like that:
    [B]document.getEle mentById('<%=Ma ster.ActiveLbl. ClientID%>').in nerText="'<%'" + s + "'%>'";[/B]

    But as we probably all know this syntax is not possible to provide the realtime result I want. Then, if the ideal solution is not possible, I try to include my script in a JScript File so I will not have to hard code all of these Switch,Case in every page of my website. However, even though when they are hardcode, the following code works fine. When I load it with the JScript file, I get a 'document.getEl ementById(...)' is null or not an object runtime script error.
    Any ideas???
    Thank you in advance, the script's code follows...

    <script type="text/javascript" >
    <!--
    function MouseOver(S)
    {
    var sStringToShow;
    switch (S)

    {
    case "BuildingVa l": sStringToShow=' <%=MyAppData.Mo useOverBuilding Val%>';
    break;
    case "ContentVal ": sStringToShow=' <%=MyAppData.Mo useOverContentV al%>';
    break;
    case "PostCode":sStr ingToShow='<%=M yAppData.MouseO verPostCode%>';
    break;
    case "Tenancy": sStringToShow=' <%=MyAppData.Mo useOverTenancy% >';
    break;
    case "getQQuote" : sStringToShow=' <%=MyAppData.Mo useOvergetQQuot e%>';
    break;
    default: sStringToShow=S ;
    }
    document.getEle mentById('<%=Ma ster.ActiveLbl. ClientID%>').in nerText = sStringToShow;

    }

    function MouseOut()
    {
    document.getEle mentById('<%=Ma ster.ActiveLbl. ClientID%>').in nerText='<%=act iveLblContent%> ';
    }
    // -->
    //change the text in an asp:Label from client side
    </script>
Working...