using methods from App_Code

i try to follow the article :

http://www.codeproject.com/KB/aspnet/ASPNETAJAXPageLoader.aspx

to create an ajax page load,
inside the code, while using
 <%
            // We have achieved a milestone. Let the user know!
            Notify("30", "Loading Departure Calendar Completed ...");
            // Simulate Internet dalay
           System.Threading.Thread.Sleep(2000);
           
             %>

from App_Code (LoadingNotifier.cs)
-------------------------------------------
namespace loader01
{

    public class LoadingNotifier : System.Web.UI.Page
    {

      public void Notify(string strPercent, string strMessage)
        {
            // Only do this on the first call to the page
            if ((!IsCallback) && (!IsPostBack))
            {
                //Update the Progress bar

                Response.Write(string.Format("<script language='javascript' type='text/javascript'>setProgress({0},'{1}'); </script>", strPercent, strMessage));
                Response.Flush();

            }

        }..

the error :
CS0103: The name 'Notify' does not exist in the current context
LVL 1
doramail05Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
guru_samiConnect With a Mentor Commented:
Do this...
1: Modify your @Page attribute like this:
<%@ Page Language="C#"  CodeFile="Default.aspx.cs" Inherits="LoadingNotifier" %>

2: Modify your default.aspx.cs file like this:
------------------
    public partial class LoadingNotifier : System.Web.UI.Page
    {
        // move everything  inside the main LoadingNotifier class in App_Code folder here      
    }

3: Delete the LoadingNotifier.cs from App_Code folder

Note: Ideally your LodingNotifier.cs should be the class inside default.aspx.cs
0
 
Dale BurrellDirectorCommented:
It sounds like you haven't got this line at the top of your page:
<%@ Page Language="C#" Inherits="LoadingNotifier" Theme="Default" %>

Open in new window

0
 
guru_samiCommented:
since you have your LoadingNotifier class inside of a namespace you will need to adjust Inhertis like:
Inherits="loader01.LoadingNotifier" ...
if that is not the case ...can we see the @Page part of your code...
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
doramail05Author Commented:
i try to put <pages theme="Default"> but has error, so i temporary removed theme.
then originally Inherits was="LoadingNotifier" as it was ambiguous, so i replaced with loader01._Default for default.aspx.cs

<%@ Page Language="C#" Inherits="loader01._Default" %>

default.aspx.cs
------------------
namespace loader01
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
0
 
doramail05Author Commented:
substitute with Inherits="loader01.LoadingNotifier".

had this error:
The type 'loader01.LoadingNotifier' is ambiguous: it could come from assembly 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\bdd130a6\787d4bb5\App_Code.gjzs0rnj.DLL' or from assembly 'C:\Documents and Settings\..\My Documents\Visual Studio 2008\Projects\loader01\loader01\bin\loader01.DLL'. Please specify the assembly explicitly in the type name.
0
 
doramail05Author Commented:
ok. changed to:

<%@ Page Language="C#" CodeFile="Default.aspx.cs" Inherits="loader1.LoadingNotifier" %>

had this error :
ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

namespace loader01
{
    public partial class LoadingNotifier : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void initNotify(string StrSplash)
        {
            // Only do this on the first call to the page
            if ((!IsCallback) && (!IsPostBack))
            {
                //Register loadingNotifier.js for showing the Progress Bar
                Response.Write(string.Format(@"<script type='text/javascript' src='scripts/loadingNotifier.js'></script>
              <script language='javascript' type='text/javascript'>
              initLoader('{0}');
              </script>", StrSplash));
                // Send it to the client
                Response.Flush();

            }

        }
        public void Notify(string strPercent, string strMessage)
        {
            // Only do this on the first call to the page
            if ((!IsCallback) && (!IsPostBack))
            {
                //Update the Progress bar

                Response.Write(string.Format("<script language='javascript' type='text/javascript'>setProgress({0},'{1}'); </script>", strPercent, strMessage));
                Response.Flush();

            }

        }

    }
}

Open in new window

0
 
guru_samiCommented:
namespace is loader01 ...but inherits has loader1
so modify to:
 Inherits="loader01.LoadingNotifier"
0
All Courses

From novice to tech pro — start learning today.