place c# inside aspx

  • Thread starter Thread starter Coder Coder
  • Start date Start date
C

Coder Coder

Hi,

I have to set the url of a link from the codebehind.

I want to call the GetLink function which returns a string.

<<a href= <<% GetLink(); %>>My Link<</a>>

- Thanks,
 
Hi,
I have to set the url of a link from the codebehind.
I want to call the GetLink function which returns a string.
<<a href= <<% GetLink(); %>>My Link<</a>>

- Thanks,

Well, if you want to do it in the .aspx file, it goes like this:

<a href="<%= GetLink() %>">Click here</a>

And GetLing() is a function that returns the link (it can be declared and
implemented in the .aspx.cs file or in the .aspx file, wherever you want).

Now, if you want to, you could use a HyperLink control and set it's
NavigateUrl property in the .aspx.cs file:

private HyperLink myLink;

public void Load(...) {
:
:
// set the URL
myLink.NavigateUrl = "/downloads/traci.mpg";
}

I hope that helps,
-JG
 
I believe this is what you're looking for:

<<a href= <<% Response.Write(GetLink()); %>>My Link<</a>>

Chris
 
Back
Top