uncomfortable mix of server and client code - how can I achieve both of these requirements
<p>I am working with a repeater control - each item on the repeater gets an image &amp; a link button. </p>

<p>From a functionality side of things, clicking the link button fires an itemcommand (supplying a commandargument as it goes). This item command then runs some serverside code to populate another repeater with data related to the first repeater as a sublist.</p>

<p>From a UI side of things, each item on the repeater has its image opacity reduced right down with exception of the clicked link buttons image.</p>

<p>This is where I run in to trouble:</p>

<pre><code>$('.showSubCats').click(function (e) {
    e.preventDefault();
                $(".myImages").animate({ opacity: 0.2 }, 300);
                $(this).parent().children('img').animate({ opacity: 1.0 }, 300);

});
</code></pre>

<p>This shows the current clicked image and hides the rest brilliantly.. BUT I had to introduce e.preventdefault() as the postback on itemcommand was obviously undoing the work jquery had just done to the images.</p>

<p>By introducing .preventdefault(), I have now lost the itemcommand as it is prevented. argh.</p>

<p>thought I have had:</p>

<ul>
<li>I tried to run a bit of jquery from code behind using registerstartupscript, but it ran before the DOM had completed and my images reverted back to 1.0 opacity</li>
<li>I tried an ajax call in my jquery to run the serverside script that way - but I couldn't get a workable solution on that</li>
<li>I tried adding {return: true};</li>
</ul>

<p>Am I flogging a dead horse with this idea or is there something else I can try? </p>

<p>here is my item command code:</p>

<pre><code>   protected void showSubCat_itemCommand(object sender, CommandEventArgs e)
    {

            using (var db = new ps.data.Entities1())
            {

                int id = int.Parse(e.CommandArgument.ToString());
                var subCats = (from sc in db.vwSubCategories
                               where sc.primaryCategoryID == id
                               select sc).ToList();

                SubCategories.DataSource = subCats;
                SubCategories.DataBind();
                currentCatChosen.Value = id.ToString();
            }
     }
</code></pre>
