A simple question.

C

ciccone1978

Hi,
Can someone help me?

I'm writing a simple web page with ASP.NET 1.1 using code-behind
technique.
Now, depending on the value of a variable declared in the code, I want
to hide/show an html
tag <a href=...></a> but actually I don't know how to do that.

I've thought to use mixed inline/code-behind in my asp page but if
I've set-up my variable
in the code-behind "myVar = MyFunc();" can I use it in the inline-code
too?

To summarize:

1) in the code-behind:

private void Page_Load(object sender, System.EventArgs e)
{
string myVar = MyFunc(); //I'm going to use this variable in other
points.
}

2) and in the inline-code

<%if(myVar=="XX") <a href=...></a>%>

But that doesn't work.
Yes, I can call the function in the inline too but it's a little heavy
or maybe I can use cache but here I've some doubts,
when the asp.page is loading which step is executed first 1) or 2)?

Some ideas?

Thanks in advance!
Bye.
 
A

Aidy

I'd use

<asp:Hyperlink>

instead and set the Visible property to true/false as needed. If you simply
want to add runat="server" to the existing <a> tag then remember you need to
declare it as such;

protected System.Web.UI.HtmlControls.HtmlAnchor myLinkID;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top