Single quote precision parameter consider as String
Hello friends,
I want to navigate my URL but there is problem with the single quote and double quote URL.
<asp:hyperlink navigateURL='file.aspx?id=<%=session("id")%>' runat=server>Link Text</asp:hyperlink>
in the above URL parameter i want to pass parameter in the single quote and this is because the Double quoted text does not work properly as it is problem in the .NET, but the problem is that the parameters mentioned in the single quoted parameter considers as String and that does not deliver the appropriate goal.
Thanks
Re: Single quote precision parameter consider as String
I use hyperlink column fine with embedded quotes with csharp like so:
<asp:HyperLink id=HyperLink1
runat="server"
Font-Size="Smaller"
ForeColor="#0000CC"
Font-Names="verdana"
NavigateUrl='<%# "?categoryid=" + DataBinder.Eval(Container.DataItem,"report_category_id") + "&office=" + Request.QueryString["office"] %>'>
<%# DataBinder.Eval(Container.DataItem,"report_category_name") %>
</asp:HyperLink>
So, change the plus signs to ampersands (and the pound sign out?) if you're using VB.
Re: Single quote precision parameter consider as String
I dont think you need an '=' again in <%=session("id")%>.
also you can put a break point always and check if the value is there for id.set the navigate url parameter in your codebehind. Code islands should be avoided if at all possible.
Re: Single quote precision parameter consider as String
Generally the proper way of setting things like that is in the code behind.However, if for whatever reason you want to do it this way, it would look more like:
NavigateUrl="~/test2.aspx?ID=<%# Bind("Id") %>" inside the element that you are setting that attribute on.