473,804 Members | 2,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ScriptManager and Form in pages created at runtime in class librar

Hello,

We have a situation where we need to create web pages in a class library and
serve them dynamically (there is no .aspx page on the web site file system).
We created a custom handler that looks like this:

/////// IHttpHandler.Pr ocessRequest implementation
Page page = new TestPage();
page.AppRelativ eVirtualPath =
context.Request .AppRelativeCur rentExecutionFi lePath;
page.ProcessReq uest(context);
//////

This is working fine. The problem is that the page we are creating
(TestPage) needs a script manager and other controls that require a form,
although I can't find a way to set the Page's form (the one returned by the
Form property) in code.

I partially solved this by adding an HtmlForm to the page, and add the other
controls to it. However, when I add a script manager to the created form, I
get a javascript error on MicrosoftAjaxWe bForms.debug.js , line 878
(this._onsubmit = this._form.onsu bmit;) saying that this._form has no
properties, which indicates that the form is not properly set (the line above
says: // TODO: Check that we found the form).

The TestPage class looks like this:

public class TestPage : Page
{
protected override void CreateChildCont rols()
{
base.CreateChil dControls();

HtmlForm form = new HtmlForm();
form.ID = "form";
Controls.Add(fo rm);

ScriptManager sm = new ScriptManager() ;
form.Controls.A dd(sm);
}
}

Any idea on how to do this?

Thanks,

Pedro Ferreira
Jun 27 '08 #1
1 1985
Ok, obviously, this was a silly mistake on my side. I forgot that I was
creating the whole page, and didn't created the <headand the <body>
elements.

It seems to be working as expected now. Sorry for the mistake.

Pedro

"Pedro Ferreira" wrote:
Hello,

We have a situation where we need to create web pages in a class library and
serve them dynamically (there is no .aspx page on the web site file system).
We created a custom handler that looks like this:

/////// IHttpHandler.Pr ocessRequest implementation
Page page = new TestPage();
page.AppRelativ eVirtualPath =
context.Request .AppRelativeCur rentExecutionFi lePath;
page.ProcessReq uest(context);
//////

This is working fine. The problem is that the page we are creating
(TestPage) needs a script manager and other controls that require a form,
although I can't find a way to set the Page's form (the one returned by the
Form property) in code.

I partially solved this by adding an HtmlForm to the page, and add the other
controls to it. However, when I add a script manager to the created form, I
get a javascript error on MicrosoftAjaxWe bForms.debug.js , line 878
(this._onsubmit = this._form.onsu bmit;) saying that this._form has no
properties, which indicates that the form is not properly set (the line above
says: // TODO: Check that we found the form).

The TestPage class looks like this:

public class TestPage : Page
{
protected override void CreateChildCont rols()
{
base.CreateChil dControls();

HtmlForm form = new HtmlForm();
form.ID = "form";
Controls.Add(fo rm);

ScriptManager sm = new ScriptManager() ;
form.Controls.A dd(sm);
}
}

Any idea on how to do this?

Thanks,

Pedro Ferreira
Jun 27 '08 #2

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

Similar topics

4
3315
by: Venus | last post by:
Hello, Thanks for your reply. I understand that a control can be created dynamically in several ways: 1) using StringBuilder 2) using Controls.Add 3) using ASP PlaceHolder But this is just for the controls and not for the form itself. What I am trying to achieve is to create an entire form (including controls)
1
7559
by: =?Utf-8?B?TGFycnkgRXBu?= | last post by:
I have an app using Ajax. The scriptmanager is within the form that is within the master page. I also have web user controls that are doing partial rendering and are "borrowing" or "inheriting" the scriptmanager from the master page. Heck, when they're rendered, the scriptmanager is on all the pages and it works. However, in the VS2005 designer, I constantly see "Can't render image" errors, and it's nearly impossible to effectively use...
0
3977
by: Krip | last post by:
When adding ASP.NET AJAX 1.0 ScriptManager and UpdatePanels to some pages in our Web Application project, we get the following error: "The type or namespace name 'ScriptManager' does not exist in the namespace 'System.Web.UI' (are you missing an assembly reference?)" This error occurs on the declaration of ScriptManager and UpdatePanel objects automatically generated in the .designer files. There is no problem for pages we ported over...
4
1727
by: WT | last post by:
Hello, How could we simulate the IsClientScriptBlocRegistered method of ClientScript when we use an update panel and the static ScriptManager ? Is this test already included in the ScriptManager.Registerxxx methods ? Regards CS
2
4894
by: abcd | last post by:
II have a asp.net application that using .NET framework 2.0. I use VS 2005. I opened VS 2008 and upgraded all the proejcts to .NET 3.5. My applicaiton has a code as below which is giving me error...any clues how to fix that... Parser Error Message: The base class includes the field 'ScriptManager', but its type (System.Web.UI.ScriptManager) is not compatible with the type of
2
1883
by: Ryan Liu | last post by:
Hi, Since ScriptManager need inside a server form, and web content page using MasterPage can not have another server form, so ajax can not be enabled (unless write own code) using ScriptManager? Any good way to solve this problem? In addition to MasterPage, is there server side include syntax as available in traditional asp page?
1
2527
by: Yan | last post by:
Hi, I'm apparently far from being the 1st one to meet this error... My asp.net ajax page requires ScriptManager.axd but gets a 404. following a lot of "This is how I solved it" posts, I : - checked my web.config (copied below) - re-installed the ajax.net extensions - ran aspnet_regiis my application
5
13663
by: Pselus | last post by:
I have a dynamically created page. The page creates an UpdatePanel (created at Design time) which has an ASP:Table (design time) in it. The table has rows with a textbox (run time) that runs some Javascript code when it is typed in. There is also a linkbutton (run time) next to this textbox that when clicked uses Ajax to reload the Javascript method. However, the Javascript is not being updated. I realize that most people post this...
16
11621
krungkrung
by: krungkrung | last post by:
Hi all, Can somebody help me figure out whats wrong with my program? I created a site with the use of MasterPage..and with a plan of utilizing and abusing the capabilities of AJAX, I added the ScriptManager to create PageMethods. Here's what I did: 1. I added the "ScriptManager" and the "JavaScript that calls the page method" in MasterPage...with Javascript inside the <body> tag and ScriptManager inside the <form> tag.
0
9705
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, 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...
0
9576
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
10568
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
10323
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...
1
10311
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,...
0
9138
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
7613
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
5647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2988
bsmnconsultancy
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...

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.