Passing parameter in Hyperlink

S

SJ

I want to pass a value in the NavigateURL property of the asp.HYPERLINK tag.
right now i'm using something like this :

asp:hyperlink id="Details" ImageUrl="images/btn.gif"
NavigateUrl='details.aspx?id=<%=p.mystring%>'

But it doesnt evaluate the <%=p.mystring%> into the actual value it
contains.
I'm sure theres a simple syntax to fix this. Any ideas?

Thanks.
 
D

Darren Kopp

If you are assigning to a string from the code behind file you could do
something like

string.Format("details.aspx?id={0}", p.mystring);

It puts the value of p.mystring where the {0} is, you can use this to
create complex strings like details.aspx?id=5&otherdata=helloworld by
just adding more {0}{1}{2} type notation and pass in more variables.

Hope this helps,
Darren Kopp
 
S

SJ

Darren Kopp said:
If you are assigning to a string from the code behind file you could do
something like

string.Format("details.aspx?id={0}", p.mystring);

It puts the value of p.mystring where the {0} is, you can use this to
create complex strings like details.aspx?id=5&otherdata=helloworld by
just adding more {0}{1}{2} type notation and pass in more variables.

Hope this helps,
Darren Kopp

Thanks, thats a good tip, but I need to do this within the aspx page and not
in the codebehind.
 
T

Tyrant Mikey

Change it as follows:

<ASP:HYPERLINK id="Details" ImageUrl="images/btn.gif"
NavigateUrl='details.aspx?id=<%# p.mystring %>'>

That is, replace the <%= with <%#
 

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
474,141
Messages
2,570,817
Members
47,365
Latest member
BurtonMeec

Latest Threads

Top