Is there a way to instantiate a page object in code and redirect the response to it? I know that this is how the actual ASP.NET engine ultimately does it under the covers. However, is this available to the developer? I want to be able to use page inheritance to create a centralized page controler without the need to build .aspx files for every page (since they would be pretty much empty shells anyway).
Here is a sample of what I "want" to do. However, the Response.Redire ct() method currently only takes a string argument and does not accept a page object reference
MyPage myPage = new MyPage()
Response.Redire ct(myPage); <---- this does not work. I wish that it would
Any ideas
Thanks
Matt 4 1750
Probably not since there is a lot more then creating a page instance, such
as creating a request and response object for the page, extracting cookies,
parsing querystrings, etc. Might as well write your own web server.
Question, with your desired behavior, how is the browser going to get the
HTML content. Unless you page objects stream the content through the
Response.Write method, you pages will not be able to display since the
code-behind does not contain the actual markup. You say that you do not
want any ASPX files, but that is where the markup is located.
If you want, you can create a sight with no ASPX files at all but rather use
an HttpHandler to intercept any ASPX calls which could then stream the
desired markup to the browser.
"mslyh" <an*******@disc ussions.microso ft.com> wrote in message
news:6B******** *************** ***********@mic rosoft.com... Is there a way to instantiate a page object in code and redirect the
response to it? I know that this is how the actual ASP.NET engine ultimately
does it under the covers. However, is this available to the developer? I
want to be able to use page inheritance to create a centralized page
controler without the need to build .aspx files for every page (since they
would be pretty much empty shells anyway). Here is a sample of what I "want" to do. However, the Response.Redire ct()
method currently only takes a string argument and does not accept a page
object reference. MyPage myPage = new MyPage(); Response.Redire ct(myPage); <---- this does not work. I wish that it
would! Any ideas? Thanks, Matt
Matt,
If your .aspx file would only be empty shells (i.e. no meaningful HTML) then
you don't need pages. Instead of actual pages create a lot of different
classes (one for each page you would have created with the logic specific to
that "page") derived from one of Control, WebControl, UserControl, or
similar classes.
Instead of redirecting to another page you controler class needs to
instantiate the appropriate control class and let it process (probably need
to add it to the controller object's Controls collection).
Eran
"mslyh" <an*******@disc ussions.microso ft.com> wrote in message
news:6B******** *************** ***********@mic rosoft.com... Is there a way to instantiate a page object in code and redirect the
response to it? I know that this is how the actual ASP.NET engine ultimately
does it under the covers. However, is this available to the developer? I
want to be able to use page inheritance to create a centralized page
controler without the need to build .aspx files for every page (since they
would be pretty much empty shells anyway). Here is a sample of what I "want" to do. However, the Response.Redire ct()
method currently only takes a string argument and does not accept a page
object reference. MyPage myPage = new MyPage(); Response.Redire ct(myPage); <---- this does not work. I wish that it
would! Any ideas? Thanks, Matt
To achieve what you are looking for you need to look at Context.Rewrite path
method and an HttpModule to pass control of the request to the page that you
specify in the rewritepath method. see http://msdn.microsoft.com/library/de...epathtopic.asp
We have a Content management system http://www.3internet.co.uk/products/inigo.aspx that does exactly what you
mention using this method. A site using our cms typically uses less than 10
templates to serve all page content, when the page is requested the path
relates to content stored in sql database which also contains details of
which template to use. In the HttpModule the request is then forwarded
using the Context.Rewrite path method to the template specified. This has
the big added bonus of allowing pages to be served without the need for
lengthy querystrings, all pages having static looking urls, which really
does make a difference in search engine positioning.
Good Luck
Matt http://www.3internet.com
"Eran Amitai" <er********@hot mail.com> wrote in message
news:ev******** ******@TK2MSFTN GP09.phx.gbl... Matt,
If your .aspx file would only be empty shells (i.e. no meaningful HTML)
then you don't need pages. Instead of actual pages create a lot of different classes (one for each page you would have created with the logic specific
to that "page") derived from one of Control, WebControl, UserControl, or similar classes.
Instead of redirecting to another page you controler class needs to instantiate the appropriate control class and let it process (probably
need to add it to the controller object's Controls collection).
Eran
"mslyh" <an*******@disc ussions.microso ft.com> wrote in message news:6B******** *************** ***********@mic rosoft.com... Is there a way to instantiate a page object in code and redirect the response to it? I know that this is how the actual ASP.NET engine
ultimately does it under the covers. However, is this available to the developer? I want to be able to use page inheritance to create a centralized page controler without the need to build .aspx files for every page (since they would be pretty much empty shells anyway). Here is a sample of what I "want" to do. However, the
Response.Redire ct() method currently only takes a string argument and does not accept a page object reference. MyPage myPage = new MyPage(); Response.Redire ct(myPage); <---- this does not work. I wish that it
would! Any ideas? Thanks, Matt
Thanks to all that answered. There were some really great ideas presented and many of them will actually acomplish what I want to do. I will do some more research on the implications of each method to decide which one will be best in my situation
Thanks again for all of the great options
Mat This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ALthePal |
last post by:
Hi,
I'm not sure if we are able to or even how to loop through the web forms in
a VB.NET project during design time. In MSAccess we are able to go through
the database -> forms collection and loop through all the forms in a database
and pull information about the form (controls and properties). We would need
to do the same in our VB.NET project; loop through the project and get the
web form's control and property information...
|
by: deko |
last post by:
I can't move a multi-page report to the last record unless I keep the popup
form (that defined it's subreports) open.
DoCmd.OpenReport "rptStandard", acViewNormal
DoCmd.Close acForm, "frmReportOptions" <== popup form
This is the error I get when I try to move to the last page of the report
*after* closing the popup:
"This expression is typed incorectly, or is too complex to be evaluate...."
|
by: Null Reference |
last post by:
Anybody here who can explain or point me to a link ?
I wish to create a blank MS Access DB file programmatically
using C# .
Thanks, nfs
|
by: R Reyes |
last post by:
Just wondering if anyone knows the pros/cons between creating a database
programmatically vs using the application's tool windows/features that come
with SQLServer, Access, Oracle, etc...
Is it the same? Does it really matter? I have created databases with .NET
programmatically and it works fine, but why would anyone want to do all this
typing when they can easily point and click inside the program?
It took a few hours of typing for...
|
by: Brian McClellan |
last post by:
Just wondering if anyone has a simple example of creating a gridview
completely programmatically, i'm not doing anything terribly sophisticated.
When creating the gridview declaratively evertying works fine, however
programmatically, while the grid will display data that exsists in the
database, any operation on the data ( editing/updating/deleting ) seems to
cause a rowdeleting/updating etc error. Or is this simply not meant to be
done?
| |
by: Kevin Frey |
last post by:
We have a data-centric application where all of the "layout" for each data
centric page is to be codified (ie. it is expressed in C# code rather than
being expressed declaratively). This codification subsequently produces the
required web-controls for a page based on whether the page is eg. in view or
update mode, examination of the user's security permissions for certain
fields, etc.
In VS2003 our "Page Master" (to use the VS2005 term)...
|
by: Greg Collins [Microsoft MVP] |
last post by:
I'm looking to discover in what event I can programmatically set this.MasterPageFile for a master page.
Documentation states that this property must be set in the PreInit or before, but master pages don't have a PreInit event -- just an Init event.
So what event is available to a master page that comes before PreInit that can be used to programmatically set the MasterPageFile property?
Thanks in advance!
--
Greg Collins
|
by: Cramer |
last post by:
According to the MSDN docs, we cannot programatically create our own themes
or skins:
"Page and control developers do not use the ControlSkinDelegate,
ControlSkin, or PageTheme classes directly. These classes are used by the
ASP.NET parser and runtime ... " (from
http://msdn.microsoft.com/en-us/library/system.web.ui.pagetheme.aspx).
My question:
Is there really no way that we can programmatically create our own themes
and have ASP.NET...
|
by: =?Utf-8?B?UGV0ZXIgSw==?= |
last post by:
I am working with Visual Studio or alternately with Expression Web. I need
to create about 50 aspx pages with about 1200 thumbnali images, typically
arranged in three to four groups per page, having hyperlinks to the
corresponding full size images.
Can anybody point me to locations in MSDN or elsewhere giving the references
to attach, the commands & objects for creating or opening the pages and
possibly available classes?
I have done...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |