mouseover on repeater to trigger update panel

Hi Experts,

I have a repeater made up of link buttons which when clicked take me to the main article on another page.

Each article has a summary and the main text, what i wish to do is on the listing page is create a summary box and when the mouse is rolled over the link button the summary of the corresponding article is displayed in it.

I'm having trouble on two counts, firstly getting  a mouseover event to run from a control in the repeater and secondly on how to get that control to trigger the update panel.

Any help appreciated.

Regards
Steve
LVL 1
fusioninternetAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fusioninternetAuthor Commented:
I have managed to make a little progress, in that i have got the summary box updating without a full postback by clicking on the links.

I have acheived this by adding the following to teh updatepanel

            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="repeaterNames" EventName="ItemCommand" />
            </Triggers>

Now if only i can get this to trigger on mouseover rather than a click all would be great
0
Steve KrileCommented:
You can add the onmouseover event during the repeater's databinding event:

In VB:

Protected Sub Repeater1_DataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
    If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
        dim lb as LinkButton = tryCast(e.Item.FindControl("MyRepeaterLinkButtonID"), LinkButton)
        lb.Attributes.Add("onmouseover", "displaySummary('" & e.Item.DataItem("TextToShow") & "')")
  end if
End Sub


that will put an onmouseover event on a link button in a repeater.  The next part of your question then is what to do once the user mouses over.  There are a lot of ways to do this, but for simplicity, let's just show an alert.

on the .aspx page:

<script type="text/javascript" language="javascript">
   function displaySummary(txt)
     {alert(txt);}
</script>
0
Steve KrileCommented:
ooh


That's good.  You could do this.  Put a hidden button on the form like this:

<asp:Button ID="hiddenButton" runat="server" style="display:none;" UseSubmitBehavior="false"  />
<asp:HiddenField id="hiddenID" runat="server" />


Add the javascript as I showed you above - but instead of entering the text into the java function, enter your ID like this:

    If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
        dim lb as LinkButton = tryCast(e.Item.FindControl("MyRepeaterLinkButtonID"), LinkButton)
        lb.Attributes.Add("onmouseover", "quietPostBack('" & e.Item.DataItem("ID") & "')")
  end if


Finally, write your javafunction to "click" the hidden button and set the HiddenID value, thus triggering the postback.


quietPostBack(idVal)
{
  var btn =  document.getElementById('<%=hiddenButton.ClientID%>');
  var hid = document.getElementById('<%=HiddenID.ClientID%>');

  hid.value = idVal;
  btn.click()
 
}


Finally, you will want to make the clicking of that button a Trigger for your update panel:

<triggers>
     <asp:AsyncPostBackTrigger ControlID="hiddenButton" EventName="Click" />
</triggers>
0
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

fusioninternetAuthor Commented:
Hi Thanks for input it makes a certain amount of sense to me apart from I'm not using vb. I don't suppose you'd know how to do the same but in c# ?

Below is the code I currently run when the textlink is clicked

        VB_NewMatterTableAdapter matterTable = new VB_NewMatterTableAdapter();
        repDetails.DataSource = matterTable.MatterGetbyID(Convert.ToInt16(e.CommandArgument));
        repDetails.DataBind();
        Label1.Visible = false;

Regards
0
Steve KrileCommented:
First, my favorite site:  http://www.developerfusion.com/tools/convert/csharp-to-vb/

Second, you won't be able to use the code you have above on a mouseover event.  That is not an event that the .net framework can pass commandarguments and such on.  onmouseover is strictly javascript.  That's why I suggest hidding a button and ID field, setting the ID value to what you are currently using your CommandArgument for,  and "clicking" it from javascript.  
0
Steve KrileCommented:
If you do that, you can handle the click event just as you have in your code - with the one exception that instead of collecting the ID from the button's CommandArgument, you will collect it from the HiddenID field.
0
Steve KrileCommented:
Where are you on this?
0
fusioninternetAuthor Commented:
In the end i used CSS to create a popup box that was populated with the information
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.