in html

<div id="dvEmpName" class="w200s">
                                <a href="#" id="basic" runat="server"><%# Eval("suppname")%></a></div>

here href id is basic which is used for the java script function

so in code add repeater itemdatabound event  


  protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem rowItem = e.Item;

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                HtmlControl btn = e.Item.FindControl("basic") as HtmlControl;
                HtmlControl rowContainer = e.Item.FindControl("dvRowData") as HtmlControl;

                if (btn != null)
                {
                    btn.Attributes.Add("onClick", string.Format("showDataRow('{0}');", rowContainer.ClientID));
                }
            }
        }
Member Avatar for stbuchok

Please refrain from putting JavaScript in your code behind. If you want to bind a JavaScript event to an element, do it in JavaScript.

Keep JavaScript separate from your page (keep in an external file)
Keep CSS separate (no inline styles, keep in external file)
HTML pages should only have HTML with references to the other resources need (js and css files).

This will also make it easier to debug later on.

Also instead of using HTMLControls, you might find it easier to use the server controls instead.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.