473,770 Members | 4,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic server side include containing a control

Hi,

I need a method to dynamically include a server side include in my
asp.net page. The problem is, the include file contains asp.net
controls, and I can't find a way to get the controls to render.

HISTORY

I have an active website. I have about 100 include files that are just
html text. In .aspx page, I have the following:

<% response.writef ile(fcnGetInclu de()) %>

Where fcnGetInclude is a function that tests the current querystring
and dynamically selects an inlcude file to write from.

Works great.

CURRENT SITUATION

Now, each of those 100 include files has an asp.net control in it.
Under the above scenario the control doesn't render because it's being
written to the page too late.

I need a way to dynamically select and include a server side include
file before the page renders on the server.

I'm open to using a database read instead of the include files, but I
believe I'll run into the same issue. The database read needs to be
done before the page is rendered on the server, so I think page_load
and page_init are too late.

Can anyone help me out?

Feb 14 '06 #1
3 1597
If you need to dyanmically render sets of functionality, you need a container
(Panel, for example) on the page. You then attach controls to the container's
panel colllection. You cannot use a "server side include" from the
traditional HTML venue (probably a way, but since you can solve this by
placing controls on the page, why spend the time?).

Here is a poor man's control loader (ascx) for numbered controls:

private void LoadControl(int controlID)
{
StringBuilder builder = new StringBuilder() ;
builder.Append( "controls\\ctl" );
builder.Append( reportDefinitio nID.ToString()) ;
builder.Append( ".ascx");

//for #1 builder.ToStrin g = "controls\ctl1. ascx"

Control userControl = LoadControl(bui lder.ToString() );
ReportControlPa nel.Controls.Ad d(userControl);
}

This should give you some ideas.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************** ************
Think Outside the Box!
*************** ************
"Larry" wrote:
Hi,

I need a method to dynamically include a server side include in my
asp.net page. The problem is, the include file contains asp.net
controls, and I can't find a way to get the controls to render.

HISTORY

I have an active website. I have about 100 include files that are just
html text. In .aspx page, I have the following:

<% response.writef ile(fcnGetInclu de()) %>

Where fcnGetInclude is a function that tests the current querystring
and dynamically selects an inlcude file to write from.

Works great.

CURRENT SITUATION

Now, each of those 100 include files has an asp.net control in it.
Under the above scenario the control doesn't render because it's being
written to the page too late.

I need a way to dynamically select and include a server side include
file before the page renders on the server.

I'm open to using a database read instead of the include files, but I
believe I'll run into the same issue. The database read needs to be
done before the page is rendered on the server, so I think page_load
and page_init are too late.

Can anyone help me out?

Feb 14 '06 #2
Ok, I think I get the idea. I'll try it out.

Thanks.

Feb 14 '06 #3
Gregory,

I wanted to followup and say thanks for this code. Taught me a good
lesson, and it's just what I needed.

Why did you feel it necessary to overload LoadControl instead giving
your subroutine it's own name? Is there something about conventions or
best practices involved?

Larry

Feb 20 '06 #4

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

Similar topics

13
2897
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when the user selects shirts another combo box called 'size' would contain sizes in relation to shirts (ie. chest/neck size). the same would occur for trousers and hats. when the user selects an option in the garment combo box, the options available...
2
1901
by: Alan Searle | last post by:
I find that I can display structured data very nicely using XML with an XSL template. As an extra 'goodie', I would like to give users the ability to sort that data (for example with a button above a particular column). What I need to know now is whether this is possible with XML/XSL? Or do I need to resort to a programming language (maybe JScript?). So far I have worked with the XML and XSL split into separate documents. However, I...
3
2136
by: IRAS Blues | last post by:
Hi all, I've got a form that consists of a bunch of textboxes and also file upload inputs. For both sets of fields, I need to be able to add in additional elements on the fly. This is done by an "Add Textbox" and "Add Upload Fields" button that I use Javascript to add to the fields. I use client-side Javascript only to add to the fields. The problem comes when I submit the form. When I submit the form, the files uploaded present no...
5
19666
by: RA | last post by:
I have created a button dynamically; which has been added to a TableCell of a TableRow of a Table control. Is there a way to add onclick event which calls a procedure on the Server-side itself. Any suggestions? I tried with btnAdd.Attributes.Add("onClick","AddItem();")
20
5650
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just client-side HTML, CSS, etc. What I want to do is somehow insert a *server control* into the , then set the server control's properties at runtime.
7
1893
by: Abraham Luna | last post by:
how do i stop the dynamic validators from breaking explorer if i use a dynamic validator and move to a different control it breaks explorer and i can type in the page when i'm not supposed to. thank you.
9
2986
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I got the core of the javascript from here: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm I noticed in the demo that sometimes the content takes a long
0
3396
bmallett
by: bmallett | last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options within options. I have everything being dynamically named from the previously dynamically named element. (I hope this makes sense.) I am not able to retrieve any of the dynamically created values. I can view them on the source page but can't pull them...
1
2964
by: jmartmem | last post by:
Greetings, I have a nagging problem with client-side dynamic dependent list boxes that perhaps someone can help me troubleshoot. I have a form with a series of dynamic dependent list boxes. Making a selection from list/box A (Qtr) selects a fiscal quarter, which then refreshes the values in list/box B (Mth), which shows the 3 months in that fiscal quarter, which then refreshes the values in list/box C (MthDate), which returns the date...
0
9602
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
10237
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...
1
10017
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
9882
tracyyun
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...
1
7431
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
5326
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
5467
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3987
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
3
2832
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.