user306905
user306905

Reputation: 29

NavigateUrl and EVAL

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

Answers (3)

ajay_whiz
ajay_whiz

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

royse41
royse41

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

Łukasz W.
Łukasz W.

Reputation: 9755

What about:

<asp:HyperLink runat="server" NavigateUrl="javascript:NavigateUrl('<%#Eval("TicketID")%>','<%=RedirectURL %>');"><%# Eval("TicketID") %></asp:HyperLink>  

Upvotes: 0

Related Questions