Search code examples
asp.netanchorhref

Pass two variables in anchor link


having the following anchor tag, I would like to pass one variable for use in the redirect form. As you see I have here the destination url and the name of the link. I'm using Request["changeId"] for get it in the form.

<td class="id"><a href='/workplace/managechange?ChangeId=<%#DataBinder.Eval(Container.DataItem, "aux_RelatedChangeID.Id")%>'><%# DataBinder.Eval(Container.DataItem, "aux_customChangeId")%></a></td>
  1. Can I pass another variable to the form, <%# DataBinder.Eval(Container.DataItem, "aux_approvalID")%>, and get it via Request?
  2. Has this variable to be visible in the url?

Thanks!


Solution

  • IT will not be possible to hide a parameter using a get request / link, if you used a form post then it would be 'hidden' from the user.

    This would require either...

    <form action="/workplace/managechange" method="post">
    <input type="hidden" name="ChangeId"  value="<%#DataBinder.Eval(Container.DataItem, "aux_RelatedChangeID.Id")%>" /> 
    
    <input type="hidden" name="approvalID" value="<%# DataBinder.Eval(Container.DataItem, "aux_approvalId")%>" />
    <input type="submit" value="Submit Values" />
    </form> 
    

    Or doing this by AJAX potentially.

    Do you need to pass both variables , could you not derive it when the managechange page / action is called?

    Also why do you need to hide this item from the query string?

    It is already public and from looking at the query string it is not seo'd, so that woudl not appear to be a reason either.

    Regards

    Steve