473,946 Members | 19,415 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="javascrip t:void(FollowLi nk('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.IsAuth enticated)
{
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 1934
<div name="signOn" runat="server"> <a href="etc"></div>
<div name="signOff" runat="server"> <a href="etc"></div>

in Page_Load()
signOn.Visible = !Request.IsAuth enticated;
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.W ebControls.Imag e

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.H tmlControls.Htm lImage

Now set the source:

Image1.Attribut es.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*******@disc ussions.microso ft.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="javascrip t:void(FollowLi nk('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.IsAuth enticated)
{
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.Visib le = !Request.IsAuth enticated;
signOff.Visibl e = !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.W ebControls.Imag e
Now, simply use the same code you gave as an example setting the imageobject's source.

Image1.ImageUr l = "/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.H tmlControls.Htm lImage

Now set the source:

Image1.Attribu tes.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*******@disc ussions.microso ft.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="javascrip t:void(FollowLi nk('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.IsAuth enticated)
{
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
5235
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 separate words separated by two dots/periods. User can enter "xyz.." also. Minimum two dots/periods must be present. Here is my code, it works partially. Please point me to the right expression. <script>
15
2794
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 option, though that is an extremely manual and time-intensive approach. Thanks, -- Benjamin
6
17320
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 there is HTML-code, for example:
1
3192
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 EventList_ItemCreated (below the html), but it's always <undefined value> (null). Everything else works fine. Eventually I need to set the value of the label depending up the Count of the DataView "dvDiscount". For now I'll settle for just finding the damn...
6
1908
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 display purposes and one is for printing. I suspect that some of the selectors in my stylesheet are no longer needed due to deletions of parts of the HTML pages and would like to remove those selectors from my stylesheets. But I'd like to avoid a...
2
2867
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. The SELECT query is built as follows: $itemtype = stripslashes(trim($_POST));
12
3424
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, etc.). Pretty much all of the functionality is working except a feature that shows in which line of the HTML source a violation of the user-set rule occurs (e.g., where a LABEL element doesn't have a FOR attribute). There doesn't seem to be a...
0
2177
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 --http://mail.google.com/mail/?realattid=f_3n2tmv&attid=0.1&disp=inline&view=att&th=10f0d56e8cb478be 24 oct 2006
15
1998
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 messed up. Both the XHTML and CSS validate without any errors or warnings. Can anyone help me figure out what is wrong? I'd be especially interested in the technique you used to figure out where the problem was. I still struggle a lot when I try to...
1
1251
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 large pages or slow servers. Does anyone know of a good way to do this? There is no guarantee that the pages are proper HTML, since this pulls from real web sites.
0
9981
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10688
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9886
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8253
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7427
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6112
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4943
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3541
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.