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

How to create my own header controls?

Hi,

a few weeks ago I had started a thread "Can't dynamically add controls
because of <%...%> code blocks". The error mentioned keeps me from inserting
an automatically generated navigation menu at the top of some pages. My
pages contain some <%= %> sections as well as sometimes <%# %> sections. Now
I have two questions:

a) Do <%# %> blocks also generate this error? In that case I couldn't use
the RepeaterControl anymore if I wanted to have my navigation menu.

b) To get rid of the error I want to replace my <%= %> blocks with server
controls. Here's the question: These blocks generate controls. How can I
possibly replace them in the header section by WHAT?

Here's a simplified example:

.aspx:

<%= generateHeader("Test.something") + generateHeader("Foo.something") %>

------

.aspx.cs:

string generateHeader(string filename)
{
return "<link href=\""+filename+"\"";
}

Axel Dahmen
Nov 19 '05 #1
2 996
<%# %> don't cause the error, because the processing is on the bind event,
its really just a string value.

simple header control:

[DefaultProperty("FileName"),
ToolboxData("<{0}:MyHeader runat=server></{0}:MyHeader >")]
public class MyHeader : System.Web.UI.WebControls.WebControl
{
private string mFileName = "";
public string FileName
{
get {return mFileName;}
set {mFileName = value;}
}
protected override void Render(HtmlTextWriter output)
{
output.Write(string.Format("<link href=\"{0}\">",mFileName));
}
}
-- bruce (sqlwork.com)
"Axel Dahmen" <NO*****@NoOneKnows.invalid> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
| Hi,
|
| a few weeks ago I had started a thread "Can't dynamically add controls
| because of <%...%> code blocks". The error mentioned keeps me from
inserting
| an automatically generated navigation menu at the top of some pages. My
| pages contain some <%= %> sections as well as sometimes <%# %> sections.
Now
| I have two questions:
|
| a) Do <%# %> blocks also generate this error? In that case I couldn't use
| the RepeaterControl anymore if I wanted to have my navigation menu.
|
| b) To get rid of the error I want to replace my <%= %> blocks with server
| controls. Here's the question: These blocks generate controls. How can I
| possibly replace them in the header section by WHAT?
|
| Here's a simplified example:
|
| .aspx:
|
| <%= generateHeader("Test.something") + generateHeader("Foo.something")
%>
|
| ------
|
| .aspx.cs:
|
| string generateHeader(string filename)
| {
| return "<link href=\""+filename+"\"";
| }
|
| Axel Dahmen
|
|
Nov 19 '05 #2
You're headed down the right path Axel. To ease the learning curve a bit
you might want to start with User Controls (.ascx files), which give you a
lot of capability without exposing you to too much of the inner plumbing at
this stage.

From a developer's perspective, a User Control is basically a mini webpage
that you embed in a larger webpage. You can reuse it across as many
webpages as you like, and within a single webpage as often as you like.
This makes it ideal for website-specific controls, like a custom header.

There are a lot of good resource on this and if you're using VS.NET, there
should be some solid example projects as well.

/// M

"Axel Dahmen" <NO*****@NoOneKnows.invalid> wrote in message
news:#C**************@TK2MSFTNGP09.phx.gbl...
Hi,

a few weeks ago I had started a thread "Can't dynamically add controls
because of <%...%> code blocks". The error mentioned keeps me from inserting an automatically generated navigation menu at the top of some pages. My
pages contain some <%= %> sections as well as sometimes <%# %> sections. Now I have two questions:

a) Do <%# %> blocks also generate this error? In that case I couldn't use
the RepeaterControl anymore if I wanted to have my navigation menu.

b) To get rid of the error I want to replace my <%= %> blocks with server
controls. Here's the question: These blocks generate controls. How can I
possibly replace them in the header section by WHAT?

Here's a simplified example:

.aspx:

<%= generateHeader("Test.something") + generateHeader("Foo.something") %>
------

.aspx.cs:

string generateHeader(string filename)
{
return "<link href=\""+filename+"\"";
}

Axel Dahmen

Nov 19 '05 #3

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

Similar topics

0
by: nail | last post by:
Hi. I have this xml file: <menu> <header caption="File"> <item header="File" caption="New File"></item> <item header="File" caption="Open File"></item> <item header="File" caption="Close...
10
by: Shapper | last post by:
Hello, I am working on an ASP.NET / VB web site and I need to have 2 versions: In English and French. I could create two versions of the web site by duplicating all the pages. Is that the...
5
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I have a sub in vb.net that adds extra headers to a gridview and it works very well. however, i tried to translate it to c# and i'm getting the header inserting itself over the first datarows and...
15
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to...
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:
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.