N
neverstill
hi-
I have <a> tags in my DataList. For the href property, I want to do
something like this:
<a href='~/Default.aspx?show=Support&disp=Faq&p=<%#
DataBinder.Eval(Container.DataItem, "name")%>' runat=server>some link</a>
Looks pretty straight forward, but when I add the runat=server property it
stops parsing the <% %> block correctly.
The workaround has been to make a method that will take 2 strings,
concatentate them, then return the result, something like this:
public string BuildUri(string a, string b)
{
return a + b;
}
then in the <a> tag I do this:
<a href='<%#BuildUri("~/Default.aspx?show=Support&disp=Faq&p=",
DataBinder.Eval(Container.DataItem, "name"))%>' runat=server>some link</a>
That works. It's a pain though cuase a) I don't understand why I need to do
it in the first place and b) my needs have changed, sometimes I will be
combining 2,3 even 4 strings to form the URI, seems dumb to have 4
overloaded methods that take more and more strings
So, what is causing this? This must have come up in the past. I tried
searching google, but I'm not sure what terms to use to describe the
problem.
If anyone has a solution (other than a function), I would love to hear it.
Thanks.
-Steve
I have <a> tags in my DataList. For the href property, I want to do
something like this:
<a href='~/Default.aspx?show=Support&disp=Faq&p=<%#
DataBinder.Eval(Container.DataItem, "name")%>' runat=server>some link</a>
Looks pretty straight forward, but when I add the runat=server property it
stops parsing the <% %> block correctly.
The workaround has been to make a method that will take 2 strings,
concatentate them, then return the result, something like this:
public string BuildUri(string a, string b)
{
return a + b;
}
then in the <a> tag I do this:
<a href='<%#BuildUri("~/Default.aspx?show=Support&disp=Faq&p=",
DataBinder.Eval(Container.DataItem, "name"))%>' runat=server>some link</a>
That works. It's a pain though cuase a) I don't understand why I need to do
it in the first place and b) my needs have changed, sometimes I will be
combining 2,3 even 4 strings to form the URI, seems dumb to have 4
overloaded methods that take more and more strings
So, what is causing this? This must have come up in the past. I tried
searching google, but I'm not sure what terms to use to describe the
problem.
If anyone has a solution (other than a function), I would love to hear it.
Thanks.
-Steve