Link to home
Start Free TrialLog in
Avatar of doramail05
doramail05Flag for Malaysia

asked on

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
Avatar of Dale Burrell
Dale Burrell
Flag of New Zealand image

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

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...
Avatar of doramail05

ASKER

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)
        {

        }
    }
}
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.
ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

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