Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Asp.net 2: Master Pages, ContentPlaceHolders and Javascript function flabbergastery

  • 16-02-2006 05:10PM
    #1
    Closed Accounts Posts: 24


    All,

    I'm trying to run a client-side javascript function on my asp.net (2) page. The page in question is actually a ContentPlaceHolder with a MasterPage (make sense to anyone?).

    So the problem is the JavaScript functions aren't defined, apparently, although they are. I can't define them in the MasterPage as that will affect the rest of the team. Anyone know how to get around this?
    P.F.
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <script language="javascript">
            function PopulateRequiredSampleSize(){
    			alert('hello'); // even this won't execute
    		}
        </script>
    
     <!-- yadda yadda yadda -->
    


    Calling it from this:
    [html]
    <input id="txtPop" type="text" onblur="PopulateRequiredSampleSize();" />
    [/html]


Comments

  • Closed Accounts Posts: 140 ✭✭Sneaky_Russian


    hate to point out the obvious but the you have a function defined called CalculateRequiredSampleSize(population) but you are are calling PopulateRequiredSampleSize()

    i take it thats a cut and paste issue as opposed to your actual problem :)


  • Closed Accounts Posts: 24 Phileas Fogg


    Cut and paste it was, fixed now.


  • Closed Accounts Posts: 140 ✭✭Sneaky_Russian


    i am a bit confused on what you are trying to do.
    i tested it it by creating a master page, then creating the client page below.
    works fine....

    [HTML]<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <script language="javascript">
    function PopulateRequiredSampleSize(){
    alert('hello'); // even this won't execute
    }
    </script>

    <input id="txtPop" type="text" onblur="PopulateRequiredSampleSize();" type=text />
    <!-- added so i can "blur" out of the above text box -->
    <input id="Text1" type="text" type=text />
    </asp:Content>
    [/HTML]


Advertisement