We help IT Professionals succeed at work.

syntax error in asp.net hyperlink

doramail05
doramail05 asked
on
syntax error found near

','questioncomment', 'resizable=no, ....

onwards.
(e.Item.FindControl("hlcomment") as HyperLink).Attributes.Add("onclick", "somename=window.open('questioncomment.aspx?qid=" + (e.Item.FindControl("lblqid") as Label).Text +
                                                                  "&qno=" + (e.Item.FindControl("lblqno") as Label).Text +
                                                                  "&childid=" + (e.Item.FindControl("lblchildid") as Label).Text','questioncomment', 'resizable=no,scrollbars=yes,status=no,toolbar=yes,height=500,width=700,left=50,top=40'); somename.focus();return true;")";

Open in new window

Comment
Watch Question

Rajkumar GsSoftware Engineer

Commented:
Try this correct code.

Raj
(e.Item.FindControl("hlcomment") as HyperLink).Attributes.Add("onclick", "somename=window.open('questioncomment.aspx?qid=" + (e.Item.FindControl("lblqid") as Label).Text +
                                                                  "&qno=" + (e.Item.FindControl("lblqno") as Label).Text +
                                                                  "&childid='" + (e.Item.FindControl("lblchildid") as Label).Text  + "','questioncomment', 'resizable=no,scrollbars=yes,status=no,toolbar=yes,height=500,width=700,left=50,top=40'); somename.focus();return true;");

Open in new window

Try below

(e.Item.FindControl("hlcomment") as HyperLink).Attributes.Add("onclick", @"somename=window.open('questioncomment.aspx?qid=" + (e.Item.FindControl("lblqid") as Label).Text +
                                                                  @"&qno=" + (e.Item.FindControl("lblqno") as Label).Text +
                                                                  @"&childid=" + (e.Item.FindControl("lblchildid") as Label).Text + "','questioncomment', 'resizable=no,scrollbars=yes,status=no,toolbar=yes,height=500,width=700,left=50,top=40'); somename.focus();return true;");

Commented:
(e.Item.FindControl("hlcomment") as HyperLink).Attributes.Add("onclick", @"somename=window.open('questioncomment.aspx?qid=" + (e.Item.FindControl("lblqid") as Label).Text +
                                                                  @"&qno=" + (e.Item.FindControl("lblqno") as Label).Text +
                                                                  @"&childid=" + (e.Item.FindControl("lblchildid") as Label).Text + "','questioncomment', 'resizable=no,scrollbars=yes,status=no,toolbar=yes,height=500,width=700,left=50,top=40'); somename.focus();return true;");

Author

Commented:
the hyperlink turns into normal text, but clickable to a specific setting browser windows.
(e.Item.FindControl("hlcomment") as HyperLink).Attributes.Add("onclick", @"somename=window.open('questioncomment.aspx?qid=" + (e.Item.FindControl("lblqid") as Label).Text +
                                                                  @"&qno=" + (e.Item.FindControl("lblqno") as Label).Text +
                                                                  @"&childid=" + (e.Item.FindControl("lblchildid") as Label).Text + "','questioncomment', 'resizable=no,scrollbars=yes,status=no,toolbar=yes,height=500,width=700,left=50,top=40'); somename.focus();return true;");

Open in new window

in the hyperlink definition add this code

hyperlink.NavigateURL="javascript:void(0)";