A small question about page Customization

Source: Internet
Author: User

A small question about page Customization

[Key word: Page]
[Test environment: OS, WINXP + SP2; development environment, Microsoft vs. net2003;. Framework, 1.1]

Some time ago, we encountered such a problem:
I have defined a general page that inherits from system. Web. UI. Page.
Public class basepage: Page {
}
After that, we made a simple inheritance:
Public class adminpage: basepage {
}
If the web form on my design page inherits from adminpage, an error occurs, prompting that the parent class cannot be implemented but cannot use the design mode.

This may be understood, because during the design, your web form should implement such a class. Of course, this class must exist. However, I did not expect the same problem to occur when I encountered the following problems:
1. There is no way to implement any pure virtual function in the page class defined by myself (during design), not to mention repeated inheritance.
2. errors may also occur when no data is accessible in all methods related to the constructor.

Here I will discuss the second case and the solution. First, let's look at one of myCode(Part ):

Public   Class Basepage: Page, iuipage
{
Fileds # Region Fileds
Protected Ivisitor m_user;
Protected Pagestypes m_pagetype;
Protected   String M_userip;
Protected System. datetime m_requesttime = System. datetime. now;
Private   Bool M_showdebugmsg;
Private   Bool M_showcopyright;
Private   Readonly   String M_copyright;
# Endregion

Public Basepage ()
{
This . M_showdebugmsg = Wavesystem. systemvarible [ " Showdebugmessage " ]. Tostring (). tolower () = " Yes " ;
This . M_showcopyright = Wavesystem. systemvarible [ " Showcopyright " ]. Tostring (). tolower () = " Yes " ;
}
}

In this example, wavesystem. systemvarible ["showdebugmessage"] obtains relevant data from the database at runtime. The consequence of this is that all web forms inherited from the basepage cannot use the design page (all in the HTML mode ). This makes me very depressed, because this information is only meaningful at runtime and the design environment is unknown, so it must also obtain wavesystem during design. systemvarible ["showdebugmessage"] value, which is obviously not implemented.

This problem was briefly discussed last time. Later I did not find a solution, so I had to replace it with a constant:
This. m_showdebugmsg = true;
This. m_showcopyright = false;

However, I encountered a method by chance today, because I cannot guarantee that the value of wavesystem. systemvarible ["showdebugmessage"] can be obtained at runtime, So I modified the Code (Part ):

Public Basepage ()
{
Try
{
This . M_showdebugmsg = Wavesystem. systemvarible [ " Showdebugmessage " ]. Tostring (). tolower () = " Yes " ;
This . M_showcopyright = Wavesystem. systemvarible [ " Showcopyright " ]. Tostring (). tolower () = " Yes " ;
}
Catch
{< br> This . m_showdebugmsg = true ;
This . m_showcopyright = false ;
}
}

I didn't expect such a change. I also passed the design mode (Note: Compile the page first ). The simple conclusion is that when designing a web form, the environment is "running" part of our code. It is not a real operation. It means there is some data that can only be obtained at runtime. If the data is accessed during the design, this error will occur.
I don't know if there is such a problem in vs. net2005, but in any case, this accidental result provides me with a solution to this problem. The problem of virtual functions and repeated inheritance remains to be solved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.