Solved

based class method is not getting called

Posted on 2014-07-24
1
360 Views
Last Modified: 2014-07-24
I have created a base "WebForm" class which is derived from asp.net Page class.
Now I want all my web pages to be dervied from this base class "WebForm".

So I did this
 public partial class Index : WebForm
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
    }
   
but when  I am running the application then asp.net is not calling "WebForm" "Page_Load" method.

I am not sure what wrong I am doing here


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace xyz
{
    public class WebForm: Page    
    {                
        private void Page_Load(object sender, System.EventArgs e)
        {            
            string strFile = Request.Url.GetLeftPart(UriPartial.Path);

            //-- For every file except the Login screen Validate the Login.
            if ((strFile.ToLower().IndexOf("SignIn") > 0))
            {
                //-- Do nothing.
            }
            else if (Session.IsNewSession | (MySession.IsExists == false))
            {
                Response.Redirect("SignIn");
            }
            else
            {
                if (MySession.CurrentUser == null)
                {
                    Response.Redirect("SignIn");
                }
            }
        }

        protected override void OnError(EventArgs e)
        {
            if (!(Request.Url.Host == "localhost"))
            {
                // At this point we have information about the error
                HttpContext ctx = HttpContext.Current;
                Exception exception = ctx.Server.GetLastError();
                
                //Try to send an error email
                try
                {
                    EmailBuilder.SendErrorMail(exception,ctx.Request);
                }
                catch
                {
                }
                ctx.Response.Write("We're sorry, there was an error. Thanks for noticing - we're going to fix it up and have things back to normal soon.");
                
                // To let the page finish running we clear the error                
                ctx.Server.ClearError();
                base.OnError(e);
            }
        }
    }
}

Open in new window

0
Comment
Question by:yadavdep
1 Comment
 
LVL 4

Accepted Solution

by:
Chris Watson earned 190 total points
ID: 40216339
In the Page_Load method in your Index page are you calling base.PageLoad() ?

public partial class Index : WebForm
{
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
    }
}

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now