please help!

Reply Forum
Forum posttim @ 2009-01-23 15:03:49
ReplyReply to
Very new to ASP.net and have a very basic question.

I'm trying to figure out how to define a variable (true) at the top of an index.aspx page and then use a conditional statement within a link to tie in an "id="select"" in the link.

Here is the PHP equivalent of what I need to do:

<? $x = 1; ?>

<a href="/about/" <? if($x == 1) echo "id=\"select\"" ?>>about us</a>

Much appreciated!


Forum postWebmaster @ 2009-01-27 19:40:52
ReplyReply to
Hi,

I really think you should be doing this from your CodeBehind file - are there any specific reason why you're not doing that? :)

Anyway, you should be able to do it like this:
<%
	bool test = true;	
%>
<a href="/About/"<% if(test) Response.Write(" id=\"selected\""); %>>Test</a>











© net-tutorials.com 2006 - 2012

MailContact net-tutorials.com