1. HTML SERVER CONTROL –Anchor (CS)
LAB WORK GUIDE
A Programme Under the compumitra Series
"A good heavy book holds you down. It's an anchor that keeps you
from getting up and having another gin and tonic."
-Roy Blount, Jr.
2. OUTLINE
ANCHOR(HTML Server Control) Using CS
Code Creation.
Output View.
Modification Trials.
Error Trials.
Practice Exercise.
Summary Review.
References.
3. ANCHOR IN HTML CONTROLS
Using "C#"
<A></A> tagset that creates hyperlinks
4. ANCHOR IN HTML CONTROL–Copy Code and Create your Own
Paste it on Notepad and
Save this Notepad with
<HTMLAnchorCS.aspx>
name In
Learner/<student-
id>/HTMLControls/
HTMLAnchor folder.
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object
sender, System.EventArgs e)
{
link1.HRef="http://www.sunmitra.com
";
link1.Target="_blank";
link1.Title="Sunmitra";
link2.HRef="http://www.compumitra.c
om";
link2.Target="_blank";
link2.Title="Compumitra";
}
</script>
<html>
<body>
<form runat="server">
<a id="link1" runat="server">Visit
Sunmitra!</a>
<br />
<a id="link2" runat="server">Visit
compumitra!</a>
</form>
</body>
</html>
5. ANCHOR IN HTML CONTROL- Run Your Own Code
For executing this Html file –
Write this Address on address bar.
http://Localhost/<StudentID>/HTMLControls/HTMLAnchor/HTMLAnchorCS.aspx
And after that, click go button.
Output On Browser
6. ANCHOR IN HTML CONTROL -Modification Trials
Add link1.InnerHtml="Visit www.sunmitra.com” ;after link.Title line in the
code.
Watch that the text of link now gets changed. Also the text already given
in the HTML section is ignored.
Now change above line to
link1.InnerHtml=“<Visit www.sunmitra.com>”;
Watch that the text of link shows the special symbols < and > around the
text. Please note that these < kind of syntax is representation of HTML
entities.
Now change above line to link1.InnerText=“<Visit
www.sunmitra.com>”;
Watch that now text of the link does not interpret the special symbols and
it gets displayed as it is.
Try removing the link1.Target=“_blank”;
Watch that now the link click doesn’t lead to a new browser window.
Try removing the line link1.Title=“Sunmitra”;
Watch that mouseover tool tip is now removed.
Try Adding link1.Visible=false;
Watch the link disappear when you try to run this code.
7. ANCHOR IN HTML CONTROLS : Error Trials
Try to Remove (" ") commas from "_blank" .
Watch the Compiler Error Message as
CS0103: The name '_blank' does not exist in the
current context.
8. ANCHOR IN HTML CONTROLS : Practice Exercise
Write a program display one button text equal
to 'Change Link' and one html link text equal to
'Visit Microsoft Site' set href is
'www.microsoft.com' .
On button click, link should be change to 'Visit
Sunmitra Site' and href is 'www.sunmitra.com'.
Click on link, links should be open in new
page.
9. ANCHOR IN HTML CONTROLS: Learning Summary Review
Use of HTML Anchor Control.
Use of Attributes of HTML Anchor
Control.
HTML Anchor
Target
Visible
Title
10. ANCHOR IN HTML CONTROLS : Bibliography
http://www.w3schools.com/aspnet/control_ht
mlAnchor.asp
http://msdn.microsoft.com/en-
us/library/system.web.ui.htmlcontrols.htmlanc
hor(v=VS.80).aspx
http://authors.aspalliance.com/aspxtreme/asp
net/syntax/htmlanchorcontrol.aspx
http://asp101.com/articles/sample_chapters/sit
epoint_byoaspnet/chapter4.asp#d0e5728
11. Ask and guide me at
sunmitraeducation@gmail.com
Share this information with as
many people as possible.
Keep visiting www.sunmitra.com
for programme updates.