0

I've a hyperlink in aspx page. I edit it like this:

 <asp:HyperLink ID="hypDuzenle" runat="server" 
         NavigateUrl='<%# String.Format("javascript:window.open('~/User/K/KPrintForm.aspx?
                    CD={0}&CT={1}&W={2}&SN={3}&MNR={4}&PNF={5}&MDT={6}',
                    'MsgWindow', 'width=200, height=100')", Eval("B_CD"), Eval("B_CZ"), 
                     Eval("B_WE"), Eval("B_SE"), Eval("MAT"), Eval("SAT"), Eval("MAN"))%>' 
                     ImageUrl="~/img/printer.png">
 </asp:HyperLink> 

However I get this error message:

Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: The server tag is not well formed.

Where can be the problem?

Krunal Mevada
  • 1,637
  • 1
  • 17
  • 28
1teamsah
  • 1,863
  • 3
  • 23
  • 43

2 Answers2

0

Better solution for this error is to set the value in code behind.

<asp:HyperLink ID="hypDuzenle" runat="server" ImageUrl="~/img/printer.png">
</asp:HyperLink>

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
        HyperLink hypDuzenle=(HyperLink)e.Row.FindControl("hypDuzenle");

        string B_CD = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "B_CD"));
        string B_CZ = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "B_CZ"));
        string B_WE = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "B_WE"));
        string B_SE = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "B_SE"));
        string MAT = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MAT"));
        string SAT = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "SAT"));
        string MAN = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "MAN"));      

        hypDuzenle.NavigateUrl="#";
        hypDuzenle.Attributes.Add("onclick", String.Format("javascript:window.open('"+ResolveUrl("~/User/K/KPrintForm.aspx")+"?CD={0}&CT={1}&W={2}&SN={3}&MNR={4}&PNF={5}&MDT={6}','MsgWindow', 'width=200, height=100')", B_CD, B_CZ, B_WE, B_SE, MAT, SAT, MAN));
    }
}
Bharatsing Parmar
  • 2,435
  • 1
  • 9
  • 18
  • Your answer would be better if you explained for both code snippets what you changed and/or why you think the code would help. Don't just give people a fish, teach them how to fish :-) – Peter B Dec 28 '16 at 13:59
  • I get this error: Server tags cannot contain <% ... %> constructs. – 1teamsah Dec 28 '16 at 15:01
  • New window opened, ok. However the main page content disappears and there is a text that is [Object] in the page. How to hold my main page content? – 1teamsah Dec 29 '16 at 08:47
  • ok, to hold main page content need to assign onclick instead of NavigateUrl. Let me update code – Bharatsing Parmar Dec 29 '16 at 08:53
  • Thanks. In addition, how to define scrollbars, addressbar visibilities and not resizable settings? – 1teamsah Dec 29 '16 at 09:39
  • You need to pass more parameter in window.open('/pageaddress.html','winname','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=350'); – Bharatsing Parmar Dec 29 '16 at 09:42
0

Replace the asp:hyperlink with a normal html tag link:

<a href='<%# String.Format("javascript:window.open('~/User/K/KPrintForm.aspx?
                    CD={0}&CT={1}&W={2}&SN={3}&MNR={4}&PNF={5}&MDT={6}',
                    'MsgWindow', 'width=200, height=100')", Eval("B_CD"), Eval("B_CZ"), 
                     Eval("B_WE"), Eval("B_SE"), Eval("MAT"), Eval("SAT"), Eval("MAN"))%>'><img src="~/img/printer.png">
         </a>
Sandeep Kumar
  • 76
  • 1
  • 7