CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004

    .net javascript masterpage conflict

    I'm not a Javascript person, so please be kind. I've got an 2 page that has a master page. I've got a javascript that works fine in a regular page within the same web. Move it to the page with the master page, and it won't work. Any help appreciated. Also, what's the difference between function setDifference(form) and setDifference = function(form)? Here's the basic stuff:

    setDifference = function(form)
    var x = document.getElementById('dtTxt1').value;
    var y = document.getElementById('dtTxt2').value;
    var dt1 = Date.parse(x)
    var dt2 = Date.parse(y)
    document.getElementById('resultTxt').value = (dt1.valueOf() - dt2.valueOf()) / (60 * 60 * 24 * 1000)
    <asp:TextBox ID="dtTxt1" name="dtTxt1" runat="server" onkeyup="BLOCKED SCRIPTsetDifference(this.form);" onkeydown="BLOCKED SCRIPTsetDifference(this.form);" /><br />
    <asp:TextBox name="dtTxt2" id="dtTxt2" runat="server" onkeyup="BLOCKED SCRIPTsetDifference(this.form);" onkeydown="BLOCKED SCRIPTsetDifference(this.form);" />
    <br /><asp:textbox name="resultTxt" id="resultTxt" runat="server" /><br /><br />
    Last edited by PeejAvery; May 12th, 2009 at 03:15 PM. Reason: Added code tags.

  2. #2
    Join Date
    May 2002

    Re: .net javascript masterpage conflict

    There are a couple of different methods for creating functions in JavaScript. The two examples below will do the exact same thing.

    var functionName = function(parameters) {...}
    function functionName(parameters) {...}
    As for your code not working on a separate page, I would suggest double checking all elements referenced. The code itself is correct. But, in JavaScript you should always line terminate with a semicolon. If you don't debugging goes defunked!!!
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width