473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to programatically load control in HTTPHandler ?

Hi. I have a web.config which says that all files with the "axd" extension
should by a special handler.

The handler writes some stats to the "axd" page.

Public Class WhosOnHandler
Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As System.Web.HttpContext)
Implements System.Web.IHttpHandler.ProcessRequest
............
context.Response.Write("<table border=1 cellpadding=4 bgcolor=orange>")
context.Response.Write("<tr><td colspan=4 align=center>")
...........
Public ReadOnly Property IsReusable() As Boolean Implements
System.Web.IHttpHandler.IsReusable
Get
Return True
End Get
End Property
End Class

Note that there *is no* axd aspx page in my project ! Whenever a user
presses on a button named "Stats", the code executes
Response.Redirect("TestForm2.aspx") and the handler detects a call to an AXD
file and takes care of the rest, as above.

My problem is that this axd file looks pretty plain, only with
"context.Response.Write". I have some custom controls which I would like to
load to make this page look consistent with the other pages on this website.

So the question is: how do I programatically load my controls in this
situation? I only have the 'Context' object and I need to somehow get to the
'Page' object to be able to say Page.Controls.Add. In other words, how do I
obtain an instance of this page ?

Thank you.
Alex
Nov 19 '05 #1
2 2503
Alex Nitulescu wrote:
Hi. I have a web.config which says that all files with the "axd" extension should by a special handler.

The handler writes some stats to the "axd" page.

Public Class WhosOnHandler
Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As System.Web.HttpContext)
Implements System.Web.IHttpHandler.ProcessRequest
...........
context.Response.Write("<table border=1 cellpadding=4 bgcolor=orange>") context.Response.Write("<tr><td colspan=4 align=center>")
..........
Public ReadOnly Property IsReusable() As Boolean Implements
System.Web.IHttpHandler.IsReusable
Get
Return True
End Get
End Property
End Class

Note that there *is no* axd aspx page in my project ! Whenever a user presses on a button named "Stats", the code executes
Response.Redirect("TestForm2.aspx") and the handler detects a call to an AXD file and takes care of the rest, as above.

My problem is that this axd file looks pretty plain, only with
"context.Response.Write". I have some custom controls which I would like to load to make this page look consistent with the other pages on this website.
So the question is: how do I programatically load my controls in this situation? I only have the 'Context' object and I need to somehow get to the 'Page' object to be able to say Page.Controls.Add. In other words, how do I obtain an instance of this page ?


If you want Page, then just use ordinary .aspx. I think the http
handler is completely useless since its URL has to end with the ext
".axd", and you could just replace it with a Page with diffenrent
content-type.

It's not easy to load a Page by yourself, because there are many issues
that ASP.NET has to deal with, such as event dispatching, postback, etc.

Nov 19 '05 #2
Alex,

You can take a look at PageParser.GetCompiledPageInstance which takes the path to the aspx you need to load and return an IHTTPhandler. Call ProcessRequest to execute the aspx page.

Willie

nntp://news.microsoft.com/microsoft.public.dotnet.framework.aspnet/<et**************@tk2msftngp13.phx.gbl>

Hi. I have a web.config which says that all files with the "axd" extension
should by a special handler.

The handler writes some stats to the "axd" page.

Public Class WhosOnHandler
Implements IHttpHandler
Public Sub ProcessRequest(ByVal context As System.Web.HttpContext)
Implements System.Web.IHttpHandler.ProcessRequest
...........
context.Response.Write("<table border=1 cellpadding=4 bgcolor=orange>")
context.Response.Write("<tr><td colspan=4 align=center>")
..........
Public ReadOnly Property IsReusable() As Boolean Implements
System.Web.IHttpHandler.IsReusable
Get
Return True
End Get
End Property
End Class

Note that there *is no* axd aspx page in my project ! Whenever a user
presses on a button named "Stats", the code executes
Response.Redirect("TestForm2.aspx") and the handler detects a call to an AXD
file and takes care of the rest, as above.

My problem is that this axd file looks pretty plain, only with
"context.Response.Write". I have some custom controls which I would like to
load to make this page look consistent with the other pages on this website.

So the question is: how do I programatically load my controls in this
situation? I only have the 'Context' object and I need to somehow get to the
'Page' object to be able to say Page.Controls.Add. In other words, how do I
obtain an instance of this page ?

Thank you.
Alex


[microsoft.public.dotnet.framework.aspnet]
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dave Bootsma | last post by:
Is it possible to programatically save a certain image from a certain web page? I want to automatically get a specific graphic from a specific web page programatically so I can automate the...
4
by: Andrea Williams | last post by:
Does anyone know of some in depth documentation regarding how to add user controls programatically? I have a User Control, which has some basic html controls, and depending on the number selected...
4
by: stb | last post by:
I have an empty asp:table on a form. Rows and cells in the rows are added programatically. At the end of each row, there is a cell with a button inside it. How do I catch the button's click...
2
by: P. Gruenhagen | last post by:
I've written several UserControls that contain different versions of a form that users need to fill out. Depending on which role a user is logged in as, I load the appropriate UserControl and add...
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
3
by: larry mckay | last post by:
I'm trying to programatically print the content that is rendered in an internet explorer control. if do webbrowser.navigate ("http://www.yahoo.com") the content of the webpage appears in the...
1
by: Trint Smith | last post by:
I know that this may belong in the asp group, but I want to programatically control the web form image control. For example, I want to let the program choose the image url at load time and the...
0
by: mike | last post by:
Hi, When I programatically Bind a DataSource to DetailsView it does not fire "ModeChanged" event. This is first time i am trying to use ASP.NET DetailsView control. I have played with some of the...
5
by: Author | last post by:
I followed the example at http://support.microsoft.com/kb/308001/EN-US/ and created my own HttpHandler. Here is the code: using System.Web; namespace MyNameSpace { public class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.