views:

41

answers:

3

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.

A: 

What about:

<asp:HyperLink runat="server" NavigateUrl="javascript:NavigateUrl('<%#Eval("TicketID")%>','<%=RedirectURL %>');"><%# Eval("TicketID") %></asp:HyperLink>  
ŁukaszW.pl
+1  A: 

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

seanxe
A: 

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?

ajay_whiz