2016-12-28 64 views
0

我在aspx頁面中有超鏈接。我編輯它是這樣的:如何解決此問題:服務器標記格式不正確

<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> 

不過,我收到此錯誤信息:

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.

哪裏是什麼問題?

+0

哪裏這個超鏈接在哪裏?你在使用GridView嗎? – Win

+0

是的,超鏈接位於DevExpress AspxGridView中。 – 1teamsah

回答

0

此錯誤的更好的解決方案是在後面的代碼中設置值。

<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)); 
    } 
} 
+0

如果您爲這兩個代碼片段解釋了您所更改的內容和/或爲什麼您認爲代碼有幫助,那麼您的答案會更好。不要只給人一條魚,教他們如何釣魚:-) –

+0

我得到這個錯誤:服務器標籤不能包含<% ... %>結構。 – 1teamsah

+0

我編輯了答案。請試試看。 –

0

更換ASP:與普通的HTML標籤鏈接超鏈接:

<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> 
相關問題