Dev006
Dev006

Reputation: 87

asp:hyperLink NavigateURL and double quote characters error

What is the correct syntax to the NavigateURL attribute of asp:HyperLink?

Error came when I used double quote characters. (Eg:-Number of "visits accessing our community" health physiotherapy services )

 <RAD:GridTemplateColumn HeaderText="KPI" DataField="DisplayName" UniqueName="KPIName" GroupByExpression="DisplayName Group By DisplayName">
                    <ItemTemplate>
                        <asp:Label Text='<%# Eval("DisplayName") %>' ID="lblKPI" runat="server" Visible="false" />
                        <asp:HyperLink runat="server" ID="lnkKpi" rel='<%# Eval("DisplayName") %>' Text='<%# Eval("DisplayName") %>' NavigateUrl='<%# Eval("KPIID","~/Authorised/PerformanceManagement/PerformanceManagement.aspx?Kpi={0}") %>' Target="_blank"></asp:HyperLink>
                    </ItemTemplate>
                </RAD:GridTemplateColumn>

Result

enter image description here

How to handle the error ?

Upvotes: 0

Views: 926

Answers (2)

saumil_
saumil_

Reputation: 323

You can do it by creating a URL in the code behind file.

See Dynamically set a hyperlink control's NavigateUrl property inline.

Upvotes: 0

VDWWD
VDWWD

Reputation: 35564

Use HtmlEncode for the values

Text='<%# HttpUtility.HtmlEncode(Eval("DisplayName")) %>'

Or

NavigateUrl='<%# "~/Authorised/PerformanceManagement/PerformanceManagement.aspx?Kpi=" + HttpUtility.HtmlEncode(Eval("DisplayName")) %>'

Upvotes: 1

Related Questions