Anchor <a name=... > tag

S

Sunny

Hi,

I would like in runtime to create some sections of the page, and at the
beginning to put some links to these sections.

Lets say I have to provide some details for every city user will visit.
I fetch the cities from the DB, and details for every city. Now I want
to have a page like this:


<p><a href="#Minneapolis">Minneapolis</a></p>
<p><a href="#Seattle">Seattle</a></p>
<p><a href="#Tokio">Tokio</a></p>
<p><a href="#Moscow">Moscow</a></p>

.........

<a name="Minneapolis"></a>
Data for Minneapolis
........

<a name="Seattle"></a>
Data for Seattle
......

etc., etc.


So far, I create a PlaceHolders for both links and detail sections, and
while I iterate my data, I generate the anchor name, and I can add the
links using HyperLink control. But I can not figure out how to add the
anchors in the second PlaceHolder.

I taught to use Literal control, but this looks ugly. Any suggestions?

Thanks

Sunny
 
M

mikeb

Sunny said:
Hi,

I would like in runtime to create some sections of the page, and at the
beginning to put some links to these sections.

Lets say I have to provide some details for every city user will visit.
I fetch the cities from the DB, and details for every city. Now I want
to have a page like this:


<p><a href="#Minneapolis">Minneapolis</a></p>
<p><a href="#Seattle">Seattle</a></p>
<p><a href="#Tokio">Tokio</a></p>
<p><a href="#Moscow">Moscow</a></p>

........

<a name="Minneapolis"></a>
Data for Minneapolis
.......

<a name="Seattle"></a>
Data for Seattle
.....

etc., etc.


So far, I create a PlaceHolders for both links and detail sections, and
while I iterate my data, I generate the anchor name, and I can add the
links using HyperLink control. But I can not figure out how to add the
anchors in the second PlaceHolder.

I taught to use Literal control, but this looks ugly. Any suggestions?

Use the System.Web.UI.HtmlControls.HtmlAnchor control class.
 
S

Sunny

Thanks a lot.
It is not in the designer toolbox, and google found only pages with
HyperLink control.

I'll give it a try.

Sunny
 
S

Steven Cheng[MSFT]

Hi Sunny,

Here are some additional reference in the MSDN which may be helpful for
getting closer to the HtmlAnchor control and the entire Html Server
Controls group:

#HtmlAnchor Control
http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconHtmlAnchorControl
.asp?frame=true

#HTML Server Controls Hierarchy
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconhtmlcontrolshierar
chy.asp?frame=true

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
S

Sunny

Hi Steven,

thanks for the links.

A quick question - is there such a beast like <BR> control?

If I want to add some Literals in a PlaceHolder, every one on a new
line, do I have to add in the Text property the <BR> tag, or there is a
programmatic way?

Thanks

Sunny
 
M

mikeb

Sunny said:
Hi Steven,

thanks for the links.

A quick question - is there such a beast like <BR> control?

If I want to add some Literals in a PlaceHolder, every one on a new
line, do I have to add in the Text property the <BR> tag, or there is a
programmatic way?

HtmlGenericControl
 
S

Sunny

Thanks for the tip.

But HtmlGeneralControl("BR") generates this:

<BR></BR>

which results in 2 linebreaks in the browser.

Sunny
 
J

John Saunders

Sunny said:
Thanks for the tip.

But HtmlGeneralControl("BR") generates this:

<BR></BR>

which results in 2 linebreaks in the browser.

Then perhaps you should surround your lines with a <div>, or else add <p>
tags in between the lines.
 
S

Sunny

Thanks John,

it seems that I should start with HTML at first :)

<p> is not suitable, as it makes a blank line.
The only HTML tag I knew that makes line breaks was <BR>, thanks for the
<div> suggestion, exactly what I needed.

Sunny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top