Solved

add text to panel in code behind

Posted on 2007-12-05
3
2,101 Views
Last Modified: 2013-11-26
In ASP.NET 2.0 with C# I have a Panel.
In the code behind I add to this panel asp:hyperlink controls:
             HyperLink hl1 = new HyperLink();
                hl1.ID = "HL1";
                hl1.NavigateUrl = "~/Index.aspx";
                hl1.Text = "Home";
                pnlbreadcrumbs.Controls.Add(hl1);

                HyperLink hl2 = new HyperLink();
                hl2.ID = "HL1";
                hl2.NavigateUrl = "~/Index.aspx";
                hl2.Text = "HyperLink2";
                pnlbreadcrumbs.Controls.Add(hl2);
After each hyperlink I want to give the > sign which is ">"
How shall I add it to the panel in the code behind?
thankyou
anat

0
Comment
Question by:ANAT2403
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
DreamMaster earned 500 total points
ID: 20410036
You could add a literal after each hyperlink control, that way you could add whatever you want behind that.

So you'd get something like this:

HyperLink hl1 = new HyperLink();
hl1.ID = "HL1";
hl1.NavigateUrl = "~/index.aspx";
hl1.Text = "Home";
pnlbreadcrumbs.Controls.Add(hl1);

Literal lit1 = new Literal();
lit1.ID = "literal1";
lit1.Text = " > ";
pnlbreadcrumbs.Controls.Add(lit1);

Haven't tested this, but it should work.

Regards,
Max.
0
 

Author Comment

by:ANAT2403
ID: 20410076
Hi Max,
I took your idea and improved it.
                Label lbl1 = new Label();
                lbl1.Text = ">";
                pnlbreadcrumbs.Controls.Add(lbl1);
thankyou
Anat
0
 
LVL 19

Expert Comment

by:DreamMaster
ID: 20410340
Both would work. ;)

Glad to have been helpful :)

Regards,
Max.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question