using databinding to codebehind in html

R

rjl

How do you use variable in html tag, such as:
<a href="<%=getVariable%>Test</a>

thanks.
 
K

Karl Seguin

Well, the ASP.Net way would be to make that a server control and access it
in your page lifecycle:

<a id="test" runat="server" />

codebehind:
Protected test as HtmlAnchor

sub Page_load(...)
Test.HRef = "Blah.aspx"
end sub


if you insist on doing the <%=getVariable%> route, you'll need to define
getVariable as a protected string.

karl
 
R

rjl

thanks, but I ahve dont that and it won't work, If I place the variable
on hte page (outside the tag description), it does render properly.
Thanks,
 
K

Karl Seguin

How and where is the variable declared? Is this inside a
repeater/datalist/datagrid?

Karl
 
K

Karl Seguin

Any time you might want to provide code :)

Are you sure it's being set ? When is it being set? If you are trying to
use it within a bound control (repeater, datalist, datagrid...), you might
need to use %# instead of %=

<a href='<%#getVariable%>'>Test</a>
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top