473,383 Members | 1,919 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,383 software developers and data experts.

querystring in masterpages - please help

Hello,

I have created a template for my website using the masterpages template
technique.
It's working fine, except when I try to print the value of a querystring
parameter in my HTML code, I get the following error:

"The Controls collection cannot be modified because the control contains
code
blocks (i.e. <% ... %>)."

which is raised from the MasterPage class. It's falling over on the
following line:

if (control.Visible) Controls.Add(control);
Here is the code in my html file.

<MP:MasterPage id="MPContainer" runat="server">
<MP:ContentRegion id="MPHeader" runat="server">My Title</MP:ContentRegion>

<% = Request.QueryString["id"] %>

<MP:ContentRegion id="MPFooter" runat="server">My Footer</MP:ContentRegion>
</MP:MasterPage>


Nov 18 '05 #1
3 1317
if your code behind creates dynamic controls you cannot use <% %> blocks in
the apsx. replace your <% = %> with a literal and set with the codebehind,
say in your site base page.

-- bruce (sqlwork.com)
"suzy" <su**@spam.com> wrote in message
news:MR******************@news-binary.blueyonder.co.uk...
Hello,

I have created a template for my website using the masterpages template
technique.
It's working fine, except when I try to print the value of a querystring
parameter in my HTML code, I get the following error:

"The Controls collection cannot be modified because the control contains
code
blocks (i.e. <% ... %>)."

which is raised from the MasterPage class. It's falling over on the
following line:

if (control.Visible) Controls.Add(control);
Here is the code in my html file.

<MP:MasterPage id="MPContainer" runat="server">
<MP:ContentRegion id="MPHeader" runat="server">My Title</MP:ContentRegion>
<% = Request.QueryString["id"] %>

<MP:ContentRegion id="MPFooter" runat="server">My Footer</MP:ContentRegion> </MP:MasterPage>



Nov 18 '05 #2
hi bruce,

thanks for the reply, i kind of understand what you are saying, but im not
sure how to fix my problem.

i am trying to set the <title> tag in my aspx page depending on a
querystring value, but my template/master page (where the title tag is
defined) is just html.

in my aspx pages i can override the title tag with plain text, but i have no
idea to do what you are suggesting, because i dont know how to reference the
title tag from my aspx page.

nb: i dont know if this matters, but i am using master pages and not page
templates, which means i am not inheriting from a base class page (ie: i
can't use the base method to reference code in my template page)

any ideas? many thanks

"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
if your code behind creates dynamic controls you cannot use <% %> blocks in the apsx. replace your <% = %> with a literal and set with the codebehind,
say in your site base page.

-- bruce (sqlwork.com)
"suzy" <su**@spam.com> wrote in message
news:MR******************@news-binary.blueyonder.co.uk...
Hello,

I have created a template for my website using the masterpages template
technique.
It's working fine, except when I try to print the value of a querystring
parameter in my HTML code, I get the following error:

"The Controls collection cannot be modified because the control contains
code
blocks (i.e. <% ... %>)."

which is raised from the MasterPage class. It's falling over on the
following line:

if (control.Visible) Controls.Add(control);
Here is the code in my html file.

<MP:MasterPage id="MPContainer" runat="server">
<MP:ContentRegion id="MPHeader" runat="server">My

Title</MP:ContentRegion>

<% = Request.QueryString["id"] %>

<MP:ContentRegion id="MPFooter" runat="server">My

Footer</MP:ContentRegion>
</MP:MasterPage>




Nov 18 '05 #3
It's OK, it was easier than I thought it would be.

Many thanks!

"suzy" <su**@spam.com> wrote in message
news:yI******************@news-binary.blueyonder.co.uk...
hi bruce,

thanks for the reply, i kind of understand what you are saying, but im not sure how to fix my problem.

i am trying to set the <title> tag in my aspx page depending on a
querystring value, but my template/master page (where the title tag is
defined) is just html.

in my aspx pages i can override the title tag with plain text, but i have no idea to do what you are suggesting, because i dont know how to reference the title tag from my aspx page.

nb: i dont know if this matters, but i am using master pages and not page
templates, which means i am not inheriting from a base class page (ie: i
can't use the base method to reference code in my template page)

any ideas? many thanks

"bruce barker" <no***********@safeco.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
if your code behind creates dynamic controls you cannot use <% %> blocks

in
the apsx. replace your <% = %> with a literal and set with the codebehind, say in your site base page.

-- bruce (sqlwork.com)
"suzy" <su**@spam.com> wrote in message
news:MR******************@news-binary.blueyonder.co.uk...
Hello,

I have created a template for my website using the masterpages template technique.
It's working fine, except when I try to print the value of a querystring parameter in my HTML code, I get the following error:

"The Controls collection cannot be modified because the control contains code
blocks (i.e. <% ... %>)."

which is raised from the MasterPage class. It's falling over on the
following line:

if (control.Visible) Controls.Add(control);
Here is the code in my html file.

<MP:MasterPage id="MPContainer" runat="server">
<MP:ContentRegion id="MPHeader" runat="server">My

Title</MP:ContentRegion>

<% = Request.QueryString["id"] %>

<MP:ContentRegion id="MPFooter" runat="server">My

Footer</MP:ContentRegion>
</MP:MasterPage>





Nov 18 '05 #4

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

Similar topics

4
by: Max | last post by:
Hello. This is the first time I've posted to a newsgroup, and I do this because I'm in desperate need of help. I'm working a user management system, and when I activate a user that has registered...
1
by: nLella | last post by:
I am trying to build a new web application and trying to implement either templates or master pages in it. I tried to read several articles but could not actually deside on weather to go with the...
3
by: suzy | last post by:
Hello, I have created a template for my website using the masterpages template technique. It's working fine, except when I try to print the value of a querystring parameter in my HTML code, I...
0
by: Matt Howeson | last post by:
Some time ago I posted a request for help with a problem I was having sometime ago whereby a 404 error would result if any access to the Querystring had been made before the Context.Rewritepath is...
2
by: iturner100 | last post by:
Hi, I've been struggling with this one for a couple of hours without much joy. Basically, I've got a set of nested masterpages (3 as it happens). I'm dynamically generating a new page in code...
6
by: Joe | last post by:
Hello All: I have a webform (WebForm1.aspx) that retrieves a value from a database (_formSessionId) the first time that it is posted. After the user filles in the form, he/she clicks a Button...
5
by: Nick Wouters | last post by:
Dear All In Classic ASP I used CSS for ALL layout. Now in ASP.NET version 2 I am testing out Masterpages as they come in very handy. It seems like it is replacing CSS for layout but what is...
3
by: Kevin Attard | last post by:
Hi, First of all, I know that frames are evil but I had to use them in this app. I have a frameset with 2 frames (msdn-like environment). The frameset page has a querystring and I need to get...
6
by: =?Utf-8?B?U3RlcGhlbiBIYXRmaWVsZA==?= | last post by:
I have two masterpages in a web application. One is used for the login and logout pages. The other is used for all other pages in the application. The difference between the two masterpages is...
3
by: pingsheng | last post by:
Dear all, I have a form with dynamically created input fields. These fields go to next page for submitting into SQL database. The thing is all fields are the same but 4 fields. So each record...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.