473,406 Members | 2,345 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,406 software developers and data experts.

finding an HTML tag using ASP.NET

VR
Hi.

I have an ASP.NET web page, with a logo written in plain
HTML. One of the tags is an image that should read
either "sign on" or "sign off" depending on whether a user
has been authenticated:

<a href="javascript:void(FollowLink('SignOn'));">
<IMG src="/graphics/TopSignOn.gif" name="TopSignOn">
</a>

I'd like to determine which image to show in my Page_Load
() in ASP.NET. Something like:

void Page_Load()
{
if (Request.IsAuthenticated)
{
obj.src = "/graphics/TopSignOff.gif";
}
else
{
obj.src = "/graphics/TopSignOn.gif";
}
}

I am not sure, though, how to declare and/or find that
obj. Is it possible? Or should I choose a different
approach?

Thanks for the help.

VR
Nov 18 '05 #1
4 1914
<div name="signOn" runat="server"><a href="etc"></div>
<div name="signOff" runat="server"><a href="etc"></div>

in Page_Load()
signOn.Visible = !Request.IsAuthenticated;
signOff.Visible = !signOn.Visible;

(You need to declare signOn and signOff as members of your class, protected
or public).
--
Pete
=============
http://www.DroopyEyes.com - Delphi source code
Audio compression components, Fast Strings, DIB Controls

Read or write article on just about anything
http://www.HowToDoThings.com

Nov 18 '05 #2
VR,

Either use a asp.net image control. Which will have the runat="server" tag
and means that it will be declared in the codebehind, or convert your html
image tab into a server control by adding the runat="server" tag to it.

The first way is probably easier (because the object's declaration will be
added to the code-behind page automatically). Just drop an "Image" from the
web form toolbox onto your page and you'll get code like this in the html.
Also in your code-behind page you'll have a new object declared: "Image1".

<asp:Image id="Image1" runat="server"></asp:Image>

The code-behind page's object declaration will look like:

Protected WithEvents Image1 As System.Web.UI.WebControls.Image

Now, simply use the same code you gave as an example setting the image
object's source.

Image1.ImageUrl = "/graphics/TopSignOff.gif";

You're other option is similar.

Add the runat="server" attribute to your image tag.

Give your image tag an id.

<img id="Image1" runat="server">

Declare a matching object on the code behind page.

Protected Image1 As System.Web.UI.HtmlControls.HtmlImage

Now set the source:

Image1.Attributes.Add("src", "/graphics/TopSignOn.gif")

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"VR" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
Hi.

I have an ASP.NET web page, with a logo written in plain
HTML. One of the tags is an image that should read
either "sign on" or "sign off" depending on whether a user
has been authenticated:

<a href="javascript:void(FollowLink('SignOn'));">
<IMG src="/graphics/TopSignOn.gif" name="TopSignOn">
</a>

I'd like to determine which image to show in my Page_Load
() in ASP.NET. Something like:

void Page_Load()
{
if (Request.IsAuthenticated)
{
obj.src = "/graphics/TopSignOff.gif";
}
else
{
obj.src = "/graphics/TopSignOn.gif";
}
}

I am not sure, though, how to declare and/or find that
obj. Is it possible? Or should I choose a different
approach?

Thanks for the help.

VR

Nov 18 '05 #3
VR
Thanks for the help.

VR
-----Original Message-----
<div name="signOn" runat="server"><a href="etc"></div>
<div name="signOff" runat="server"><a href="etc"></div>

in Page_Load()
signOn.Visible = !Request.IsAuthenticated;
signOff.Visible = !signOn.Visible;

(You need to declare signOn and signOff as members of your class, protectedor public).
--
Pete
=============
http://www.DroopyEyes.com - Delphi source code
Audio compression components, Fast Strings, DIB Controls

Read or write article on just about anything
http://www.HowToDoThings.com

.

Nov 18 '05 #4
VR
Thanks for the help.

VR
-----Original Message-----
VR,

Either use a asp.net image control. Which will have the runat="server" tagand means that it will be declared in the codebehind, or convert your htmlimage tab into a server control by adding the runat="server" tag to it.
The first way is probably easier (because the object's declaration will beadded to the code-behind page automatically). Just drop an "Image" from theweb form toolbox onto your page and you'll get code like this in the html.Also in your code-behind page you'll have a new object declared: "Image1".
<asp:Image id="Image1" runat="server"></asp:Image>

The code-behind page's object declaration will look like:

Protected WithEvents Image1 As System.Web.UI.WebControls.Image
Now, simply use the same code you gave as an example setting the imageobject's source.

Image1.ImageUrl = "/graphics/TopSignOff.gif";

You're other option is similar.

Add the runat="server" attribute to your image tag.

Give your image tag an id.

<img id="Image1" runat="server">

Declare a matching object on the code behind page.

Protected Image1 As System.Web.UI.HtmlControls.HtmlImage

Now set the source:

Image1.Attributes.Add("src", "/graphics/TopSignOn.gif")

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"VR" <an*******@discussions.microsoft.com> wrote in messagenews:03****************************@phx.gbl...
Hi.

I have an ASP.NET web page, with a logo written in plain
HTML. One of the tags is an image that should read
either "sign on" or "sign off" depending on whether a user has been authenticated:

<a href="javascript:void(FollowLink('SignOn'));">
<IMG src="/graphics/TopSignOn.gif" name="TopSignOn">
</a>

I'd like to determine which image to show in my Page_Load () in ASP.NET. Something like:

void Page_Load()
{
if (Request.IsAuthenticated)
{
obj.src = "/graphics/TopSignOff.gif";
}
else
{
obj.src = "/graphics/TopSignOn.gif";
}
}

I am not sure, though, how to declare and/or find that
obj. Is it possible? Or should I choose a different
approach?

Thanks for the help.

VR

.

Nov 18 '05 #5

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

Similar topics

1
by: Sudhakar Doddi | last post by:
Greetings, I am a novice in Javascript and I am not able to succeed finding right regular expression for my requirement. Input in HTML form should be in the format of row.rack.bin i.e three...
15
by: Benjamin Rutt | last post by:
Are there any C tools that can find redundant #includes in a project, so as to shorten compile time? Of course, eliminating single #includes by hand and determining if the recompile fails is one...
6
by: Hans Kamp | last post by:
Is it possible to write a function like the following: string ReadURL(string URL) { .... } The purpose is that it reads the URL (determined by the parameter) and returns the string in which...
1
by: Doug | last post by:
The html below shows DataList "DiscountList" nested within DataList "EventItemList". DiscountList contains a Label control. I'm trying to find the label, using FindControl, during...
6
by: Rhino | last post by:
What's the simplest way to determine which, if any, of my selectors are not needed in a given stylesheet? I have a small number of HTML pages that share two stylesheets; one stylesheet is for...
2
by: ElkGroveR | last post by:
Hi there! I'm using PHP to create a simple, dynamic MySQL SELECT query. The user chooses a selection from a HTML Form SELECT element's many options and submits the form via a POST action. ...
12
by: e271828 | last post by:
Hi, I'm helping to work a developer tool that verifies a given HTML element has a given attribute (e.g., that all LABEL elements have a FOR attribute, all INPUT elements have an ID attribute,...
0
by: U S Contractors Offering Service A Non-profit | last post by:
This Sunday the 26th 2006 there will be Music @ Tue Nov Inbox Reply Craig Somerford to me show details 9:54 pm (26 minutes ago) #1St "CLICK" HeAt frOm A blanket...
15
by: rhino | last post by:
I've put together a prototype of two-tiered CSS tabs that works really well in IE6, IE7, and FF2. It also works very well in Opera 9.27 _except_ that the placement of the lower tier of tabs is...
1
by: jehugaleahsa | last post by:
Hello: Currently, I have a system that will use Regex to find tags in a string of HTML. Recently my company needs me to read the HTML dynamically from a stream, so as to avoid long waits on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.