我是一個有點卡住我一直在試圖找出什麼是錯了好久了的,這是以前的工作,然後它突然停了下來。錯誤我得到的是:奇怪解析錯誤--The服務器標籤不規範
Server Error in '/' Application. 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.
Source Error:
Line 20: <tr>
Line 21: <td width="200" valign="top" align="center">
Line 22: <img id="imageShow" runat="server" src="<%# DataBinder.Eval( Container.DataItem, "Link") %><%# DataBinder.Eval(Container.DataItem, "ImageName")%>" width="200px" height="150px" onclick ="ShowImage" alt="already done" />
Line 23: </td>
Line 24: <td width="200">
源文件:/WebForm1.aspx行:22
我的代碼看起來是這樣的:
<asp:Panel id="pnlShowItems" runat="server">
<asp:DataList id="d1Items" runat="server" DataKeyField="ImageID" >
<ItemTemplate>
<table width="400" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="200" valign="top" align="center">
<img id="imageShow" runat="server"
src="<%# DataBinder.Eval( Container.DataItem, "Link") %><
%# DataBinder.Eval(Container.DataItem, "ImageName")%>" width="200px" height="150px"
onclick ="ShowImage" alt="already done" />
</td>
<td width="200">
<strong><%# DataBinder.Eval( Container.DataItem, "Link") %></strong>
<br />
Cost: $<%# DataBinder.Eval(Container.DataItem, "PageDetailID")%><br /><br />
<asp:Button id="btnAddToCart" runat="server"
Text="Add To Cart" CommandName="Edit"/>
</td>
</tr>
<tr>
<td colspan="2" width="400"><hr height="1" />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
和後面的代碼是這樣的:
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn;
SqlCommand comm;
SqlDataReader reader;
string connectionString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;
conn = new SqlConnection(connectionString);
comm = new SqlCommand(@"SELECT ImageID, RTRIM(LTRIM(ImageName)) ImageName, Description, 'Images/' Link, PageDetailID FROM dbo.Images", conn);
conn.Open();
reader = comm.ExecuteReader();
reader.Read();
d1Items.DataSource = reader;
d1Items.DataBind();
conn.Close();
}
public void ShowImage()
{
DataListItem dli = this.d1Items.Controls[this.d1Items.Controls.Count - 1] as DataListItem;
Image img = dli.FindControl("imageShow") as Image;
Image1.ImageUrl = img.ImageUrl;
}
任何想法?由於
什麼'Image1'在'Image1.ImageUrl = img.ImageUrl;'? –
此搜索只是一個形象我是爲了顯示,裝載了我已經綁定了之後的圖像。不知道爲什麼Image1看起來像一個類而不是標識符 – user1279734
任何人?我可以請一些幫助嗎? – user1279734