Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2008, 07:29 AM
Authorized User
 
Join Date: Jun 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 8, href and HRef (p. 285)

In Banner.ascx we have two HTML elements, each inside an ASP panel:

<a href="http://p2p.wrox.com" target="_blank" runat="server" id="lnkVertical">

<a href="http://p2p.wrox.com" target="_blank" runat="server" id="lnkHorizontal">.

In Banner.ascx.cs we use the variables lnkVertical.HRef and lnkHorizontal.HRef to refer to the embedded URLs.

If I didn't have this example from the book, where could I find out that the "href" attribute of an HTML anchor has to be described as "HRef" in C#? Is there some standard reference work for such things?
 
Old June 16th, 2008, 09:08 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You generally shouldn't need to modify standard HTML tags/elements with the "runat='server'" attribute. For most there is a suitable server control alternative. Particularly in this case you should use the "asp:hyperlink" control instead of a modified "a" tag. However, you can modify practically every HTML tag as you have done to make it visible on the server. When you do this the control will be one found in the System.Web.UI.HtmlControls namespace. In this case your "<a ... runat='server'..." will become an HtmlAnchor control. Look here for the members list, in which you'll find the HRef property.

-Peter
compiledthoughts.com
 
Old June 16th, 2008, 10:40 AM
Authorized User
 
Join Date: Jun 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, Peter, for the helpful explanation.





Similar Threads
Thread Thread Starter Forum Replies Last Post
using href in xslt rajesh_css XSLT 0 September 18th, 2008 02:44 AM
REGEX to get href="#" monfu BOOK: Beginning Regular Expressions 2 July 24th, 2008 11:46 AM
href darkhalf Javascript 2 November 20th, 2005 10:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.