locked
pageLoad() isn't fired RRS feed

  • Question

  • User1024191908 posted

    hi

    I have an *.ascx user control and have a pageLoad function for it:

    <script type="text/javascript">
        function pageLoad(sender, e)
        {
            alert('hi');
        }
    </script>

    It is rarely fired as I refresh the page so many times event using Ctrl + F5

    what could be the problem?

    thanks in advance.

    Monday, February 26, 2018 12:00 PM

Answers

All replies

  • User475983607 posted

    Did you include the  ASP scriptmanager in the master or client page? 

    https://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager(v=vs.110).aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 26, 2018 2:25 PM
  • User1024191908 posted

    yes I have included that tag.

    Tuesday, February 27, 2018 5:17 AM
  • User-707554951 posted

    Hi anooshiravan

     You should call pageload function, 

    code as below: 

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl3.ascx.cs" Inherits="CaseTest.CaseTest.WebUserControl3" %>
    <script type="text/javascript">
        function pageLoad(sender, e)
        {
            alert("1234");
        }
        pageLoad();
    </script>
    <asp:TextBox ID="TextBox1" runat="server" Text =" Control in user control"></asp:TextBox>
     <form id="form1" runat="server">
        <div>
            <uc1:WebUserControl3 runat="server" id="WebUserControl3" />
        </div>
        </form>

    Output:

    Best regards

    Cathy

    Tuesday, February 27, 2018 6:20 AM