0

I am trying to pass an ID as a query string to another page. this is the hyper link code:

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='../request/inforequest.aspx?ID=     + <%# Eval(ID) %>' Target='_BLANK' Text='Request a Showing' alt='Request a Showing' border='0'
                                CssClass="btn btn-primary"></asp:HyperLink>

This is the resulting url:

http://localhost:51378/request/inforequest.aspx?ID=%20+%20<%# Eval(ID) %>

It is passing the id, 20 is the correct value in this case but it only adds it where there are spaces, I dont understand what is happening here can someone please help?

3
  • it's not passing the id 20, it's passing %20 which is a encoded space character... Commented Aug 28, 2014 at 16:14
  • why there is a + at the beginning? Commented Aug 28, 2014 at 16:14
  • i guess its not working at all then, i am new to asp forgive my ignorance Commented Aug 28, 2014 at 16:18

2 Answers 2

1

This should work correctly

<asp:hyperlink runat="server" navigateurl='<%# string.Concat("../request/inforequest.aspx?ID=", Eval("ID"))%>' target="_blank" Text="Click Here" />

Source

http://forums.asp.net/t/973441.aspx?How+to+Concat+String+in+aspx+page

Sign up to request clarification or add additional context in comments.

Comments

0

Try this?

<asp:HyperLink ID="HyperLink1" runat="server" 
    NavigateUrl='~/request/inforequest.aspx?ID=<%# Eval("ID") %>' target="_blank" 
    Text="Request a Showing" alt="Request a Showing" border="0"
    CssClass="btn btn-primary">
</asp:HyperLink>

5 Comments

same thing as above, it just passes <%# Eval(ID) %> to the url. I've tried all manner of combinations of quotes and i either get a This tag is not well formed error or it just wont evaluate the Eval
What specific error did you get with this version, and what link was generated in the output?
this was the URL localhost:51378/request/inforequest.aspx?ID=<%# Eval(ID) %>
i add double quotes around ID in the Eval and the syntax highlighting seemed to recognize it but then i get a parser error The server tag is not well formed.
The reason you got the error is because you can't have two sets of similar quote types for a single attribute value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.