Reputation: 29
I am trying to Navigate URL in this way
<asp:HyperLink runat="server" NavigateUrl='javascript:NavigateUrl("<%#Eval("TicketID")%>","<%=RedirectURL %>");'><%# Eval("TicketID") %></asp:HyperLink>
but an error occurred in the javascript Error Console in Mozilla browser.
Error: missing ) after argument list Source File: javascript:NavigateUrl("<%#Eval("TicketID")%>","<%=RedirectURL%20%>"); Line: 1, Column: 22 Source Code: NavigateUrl("<%#Eval("TicketID")%>","<%=RedirectURL %>");
I want to remove the error. but functionality is ok.
Upvotes: 1
Views: 1899
Reputation: 17931
See that actual values of TicketID & RedirectURL are not being rendered. asp:HyperLink is a server control. <%#...%> is a binding tag. is the control being databound?
Upvotes: 0
Reputation: 2368
Looks like you're in a repeater. The best way to do this would be to bind the hyperlink NavigateURL in the ItemDataBound event.
void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
HyperLink hyperLink = (HyperLink)e.Item.FindControl("hyperLinkid");
hyperLink.NavigateURL = "url";
}
}
That's very rough code but it's enough to give you a starting point!
Cheers, Sean
Upvotes: 1
Reputation: 9755
What about:
<asp:HyperLink runat="server" NavigateUrl="javascript:NavigateUrl('<%#Eval("TicketID")%>','<%=RedirectURL %>');"><%# Eval("TicketID") %></asp:HyperLink>
Upvotes: 0