I am using a datalist inside which I have defined an itemtemplate. I am using asp:LinkButton inside this itemtemplate. I have used an OnClick="methodname" in this linkbutton tag. I have the corresponding mehtodname defined in my code behind, However I keep getting a Java runtime error when the page loads up and when I click on any of the items in the datalist. It says that I have not javascript function function defined with the name mentioned.
Isnt asp:LinkButton a server control. I want to use my c# code behind and not javascript. How do I proceed??
<asp:DataList ID="DLID" RepeatColumns="5"
RepeatDirection="Horizontal" runat="server"
>
<ItemTemplate
>
<div class="home"
>
<div class="homeblock"
></div
>
<div class="homeitem"
>
<ul
><li
><span style="font-size:small;"
>
<asp:LinkButton ID="TopItem" runat="server" OnClick="Item_OnClick"
><%# Container.DataItem %
></asp:LinkButton
>
</span
></li
></ul
>
</div
>
</div
>
</ItemTemplate
>
</asp:DataList
>
Works perfectly fine for me. Used your markup code minus the class names. Here is the code-behind I used:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string[] ds = new string[] { "a", "b", "c", "d", "e", "f", "g" };
DLID.DataSource = ds;
DLID.DataBind();
}
}
protected void Item_OnClick(object sender, EventArgs e)
{
//do stuff
}
What is the exact error message?