473,804 Members | 3,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trying to create a Page by code

In a C# Web Control library I created this Page / HttpHandler:
=============== =
namespace WebUtils
{
public class FTBImageGallery : Page
{
public override void ProcessRequest( HttpContext context)
{
base.ProcessReq uest(context);
}
protected override void CreateChildCont rols()
{
Button but = new Button();
but.Text = "Hello :-)";
but.ID = "myButton";
Controls.Add(bu t);
}
}
}
=============== =

in a web project using this library I wrote this http handler
=============== =
<%@ WebHandler Language="C#" Class="IGallery " %>

using System;
using System.Web;

using WebUtils;

public class IGallery : FTBImageGallery
{
}
=============== =

When I try to query this HttpHandler I get the following error when calling base.ProcessReq uest(context)

=============== =
System.Web.Http UnhandledExcept ion was unhandled by user code
Message="Except ion of type 'System.Web.Htt pUnhandledExcep tion' was thrown."
Source="System. Web"
ErrorCode=-2147467259
StackTrace:
at System.Web.UI.P age.HandleError (Exception e)
at System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est()
at System.Web.UI.P age.ProcessRequ estWithNoAssert (HttpContext context)
at System.Web.UI.P age.ProcessRequ est(HttpContext context)
at WebUtils.FTBIma geGallery.Proce ssRequest(HttpC ontext context) in F:\MyWork\WebLi brary\WebUtils\ WebUtils\FTBIma geGallery.cs:li ne 19
at System.Web.Http Application.Cal lHandlerExecuti onStep.System.W eb.HttpApplicat ion.IExecutionS tep.Execute()
at System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean& completedSynchr onously)
=============== =

Any idea of what could have gone wrong?

--
I have taken a vow of poverty. If you want to really piss me off, send me money.

Jan 17 '06 #1
2 1704
Never mind, thanks to Reflector and the web deployment tool I figured out how to write this working (although still mysterious looking) code. I guess tomorrow I will just have to understand it!
=============== =
public class FTBImageGallery : Page
{
public FTBImageGallery ()
{
}
public override void ProcessRequest( HttpContext context)
{
base.ProcessReq uest(context);
}
protected override void FrameworkInitia lize()
{
base.FrameworkI nitialize();
this.__BuildCon trolTree(this);
//base.AddWrapped FileDependencie s(default_aspx. __fileDependenc ies);
base.Request.Va lidateInput();
}
private void __BuildControlT ree(FTBImageGal lery __ctrl)
{
this.Initialize Culture();
IParserAccessor accessor1 = __ctrl;
accessor1.AddPa rsedSubObject(n ew LiteralControl( "\r\n\r\n<!DOCT YPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d\">\r\n\r\n<ht mlxmlns=\"http://www.w3.org/1999/xhtml\" >\r\n"));
HtmlHead head1 = this.__BuildCon trol__control2( );
accessor1.AddPa rsedSubObject(h ead1);
accessor1.AddPa rsedSubObject(n ew LiteralControl( "\r\n<body style=\"backgro und-color:#FFFFA0\" >\r\n "));
HtmlForm form1 = this.__BuildCon trolform1();
accessor1.AddPa rsedSubObject(f orm1);
accessor1.AddPa rsedSubObject(n ew LiteralControl( "\r\n</body>\r\n</html>\r\n"));
}
private HtmlForm __BuildControlf orm1()
{
HtmlForm form1 = new HtmlForm();
form1.ID = "form1";
IParserAccessor accessor1 = form1;
accessor1.AddPa rsedSubObject(n ew LiteralControl( "\r\n <div>\r\n\t\t") );

Button but = new Button();
but.Text = "Hello :-)";
but.ID = "myButton";
accessor1.AddPa rsedSubObject(b ut);

return form1;
}
private HtmlHead __BuildControl_ _control2()
{
HtmlHead head1 = new HtmlHead("head" );
HtmlTitle title1 = this.__BuildCon trol__control3( );
IParserAccessor accessor1 = head1;
accessor1.AddPa rsedSubObject(t itle1);
return head1;
}
private HtmlTitle __BuildControl_ _control3()
{
HtmlTitle title1 = new HtmlTitle();
IParserAccessor accessor1 = title1;
accessor1.AddPa rsedSubObject(n ew LiteralControl( "Untitled Page"));
return title1;
}
}
=============== =
"Lloyd Dupont" <net.galador@ld > wrote in message news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
In a C# Web Control library I created this Page / HttpHandler:
=============== =
namespace WebUtils
{
public class FTBImageGallery : Page
{
public override void ProcessRequest( HttpContext context)
{
base.ProcessReq uest(context);
}
protected override void CreateChildCont rols()
{
Button but = new Button();
but.Text = "Hello :-)";
but.ID = "myButton";
Controls.Add(bu t);
}
}
}
=============== =

in a web project using this library I wrote this http handler
=============== =
<%@ WebHandler Language="C#" Class="IGallery " %>

using System;
using System.Web;

using WebUtils;

public class IGallery : FTBImageGallery
{
}
=============== =

When I try to query this HttpHandler I get the following error when calling base.ProcessReq uest(context)

=============== =
System.Web.Http UnhandledExcept ion was unhandled by user code
Message="Except ion of type 'System.Web.Htt pUnhandledExcep tion' was thrown."
Source="System. Web"
ErrorCode=-2147467259
StackTrace:
at System.Web.UI.P age.HandleError (Exception e)
at System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est()
at System.Web.UI.P age.ProcessRequ estWithNoAssert (HttpContext context)
at System.Web.UI.P age.ProcessRequ est(HttpContext context)
at WebUtils.FTBIma geGallery.Proce ssRequest(HttpC ontext context) in F:\MyWork\WebLi brary\WebUtils\ WebUtils\FTBIma geGallery.cs:li ne 19
at System.Web.Http Application.Cal lHandlerExecuti onStep.System.W eb.HttpApplicat ion.IExecutionS tep.Execute()
at System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean& completedSynchr onously)
=============== =

Any idea of what could have gone wrong?

--
I have taken a vow of poverty. If you want to really piss me off, send me money.

Jan 17 '06 #2
In the end I came up with that:
(what do you think?)
==============
using System.Web.UI;
using System.Web.UI.H tmlControls;

namespace WebUtils
{
public class CodePage : Page
{
public bool ValidateRequest = false;

protected override void FrameworkInitia lize()
{
base.FrameworkI nitialize();
InitializeCultu re();
BuildPage();
Title = Title;
if(ValidateRequ est)
Request.Validat eInput();
}
public readonly HtmlForm MainForm = new HtmlForm();
public readonly HtmlHead Head = new HtmlHead();
HtmlTitle pageTitle = new HtmlTitle();
public readonly HtmlGenericCont rol Body = new HtmlGenericCont rol("body");

public new string Title
{
get { return base.Title; }
set
{
pageTitle.Text = value;
base.Title = value;
}
}

protected virtual void BuildPage()
{
Head.Controls.A dd(pageTitle);
Body.Controls.A dd(MainForm);
MainForm.Contro ls.Add(new LiteralControl( "\r\n"));

Controls.Add(ne w LiteralControl( "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\" >\r\n"));
Controls.Add(He ad);
Controls.Add(ne w LiteralControl( "\r\n"));
Controls.Add(Bo dy);
Controls.Add(ne w LiteralControl( "\r\n</html>\r\n"));
}
}
}
==============

"Lloyd Dupont" <net.galador@ld > wrote in message news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..

In a C# Web Control library I created this Page / HttpHandler:
=============== =
namespace WebUtils
{
public class FTBImageGallery : Page
{
public override void ProcessRequest( HttpContext context)
{
base.ProcessReq uest(context);
}
protected override void CreateChildCont rols()
{
Button but = new Button();
but.Text = "Hello :-)";
but.ID = "myButton";
Controls.Add(bu t);
}
}
}
=============== =

in a web project using this library I wrote this http handler
=============== =
<%@ WebHandler Language="C#" Class="IGallery " %>

using System;
using System.Web;

using WebUtils;

public class IGallery : FTBImageGallery
{
}
=============== =

When I try to query this HttpHandler I get the following error when calling base.ProcessReq uest(context)

=============== =
System.Web.Http UnhandledExcept ion was unhandled by user code
Message="Except ion of type 'System.Web.Htt pUnhandledExcep tion' was thrown."
Source="System. Web"
ErrorCode=-2147467259
StackTrace:
at System.Web.UI.P age.HandleError (Exception e)
at System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est(Boolean includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
at System.Web.UI.P age.ProcessRequ est()
at System.Web.UI.P age.ProcessRequ estWithNoAssert (HttpContext context)
at System.Web.UI.P age.ProcessRequ est(HttpContext context)
at WebUtils.FTBIma geGallery.Proce ssRequest(HttpC ontext context) in F:\MyWork\WebLi brary\WebUtils\ WebUtils\FTBIma geGallery.cs:li ne 19
at System.Web.Http Application.Cal lHandlerExecuti onStep.System.W eb.HttpApplicat ion.IExecutionS tep.Execute()
at System.Web.Http Application.Exe cuteStep(IExecu tionStep step, Boolean& completedSynchr onously)
=============== =

Any idea of what could have gone wrong?

--
I have taken a vow of poverty. If you want to really piss me off, send me money.

Jan 17 '06 #3

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

Similar topics

2
2323
by: Gill Bates | last post by:
I'm trying to login to a banking site (https://www.providentconnection.com) using vb.net. I've tried many variations of WebClient and HttpWebRequest; none of which I've got to work. My latest version is: Dim myWebClient As New WebClient Dim nvc As New NameValueCollection nvc.Add("Login", username) nvc.Add("Password", password)
4
2465
by: Mark J. McGinty | last post by:
Greets, Part of the content of one of our web pages uses wingdings and Chr(239) through Chr(242) (which are little arrow outlines, though that's not really important.) It worked just fine in Windows 2000 Server, but now under Server 2003 it seems that characters above 127 get converted somehow, and our code no longer produces the desired effect.
6
2305
by: Frank Wilson | last post by:
Tom, It sounds to me like ASP, not ASP.NET is handling the request for WebForm1.aspx. This is most likely an IIS config issue that may have been caused by order of installation or reinstallation, or possibly even something that happened in IIS before .NET was installed. Here is a way to prove or disprove my theory:
2
1429
by: Paul K | last post by:
I'm trying to understand how to implement logic I currently have in an ASP application in an ASP.NET application. In ASP I have an entry application that draws an html table for a specified week. The columns are the days for the week and the rows are activities. The day being currently modified has textboxes and textareas in each cell.
3
2097
by: Kenneth P | last post by:
Hi, I have a very good book on asp.net Sams ASP.NET Tips, Tutorials and Code ISBN 0-672-32143-2 and is trying to teach myself from examples from this book Chapter 16. Anyway I come quite close when trying to run one example but then I get this message I don't understand: "This .resources file shouldn't be used with this reader. Your resource
1
1611
by: Paloma García | last post by:
Dear all, I have created personalized configuration sections in my web project following the instructions described in this page http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconDeclaringCustomConfigurationSections.asp The problem is that I using the same code and I get the error "Object reference not set to an instance of an object" in the line where I try to read the first parameter (in the page...
18
3399
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site relies on subscrption fees. Sessions ID's are matched between the browser and the server. So a users can login with same username and password and those sessions are tracked individually. Some suggest create table fields with the session ID...
5
3795
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public List<RoleData> GetRoles() { return GetRoles(null, false); }
4
1444
by: pek | last post by:
I created a file name image.php which contains only the following code: <?php function createThumbnail($picture,$thumb,$new_w,$new_h) { $extension=substr($picture,strrpos($picture,".")+1); switch (strtolower($extension)) { case "jpg": case "jpeg": $src_img=imagecreatefromjpeg($picture); break;
6
3364
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in the past in other places, and while the help was much appreciated, it seemed everyone just wanted to 'theoretically' explain how to do it, but when I tried to do it myself, I couldn't login. I want to simply pass the email address and password to...
0
9572
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10562
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, 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...
0
10319
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9132
agi2029
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...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5508
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...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4282
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
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.