Trigger UpdatePanel on mouse over (as tooltip) - asp.net

I need to display additional information, like a tooltip, but it's a lot of info (about 500 - 600 characters) on the items in a RadioButtonList.
I now trigger the update on a PanelUpdate when the user selects an item in the RadioButtonList, using OnSelectedIndexChanged and AutoPostBack. What I would like to do, is trigger this on onMouseHover (ie. the user holds the mouse a second or two over the item) rather than mouse click but I cannot find a way to do this.

You could try setting an AsyncPostBackTrigger on the updatePanel to watch the value of a hidden field. Then in the javascript onMouseHover event, increment the hidden value. This would fire the AsyncPostBackTrigger, updating the UpdatePanel.

Related

Selecting an item from a listbox fires a prerender event that removes the focus from it

I am creating an ASP.net application. I fill a ListBox control with items and I use the PreRender event of the Listbox to set its width according to the largest item in the control.
But after the ListBox is rendered, the first time I click an item in the ListBox the PreRender event fires and focus is removed from the ListBox (this event fires unnecessarily because the ListBox is already rendered). The second time I click on an item in ListBox the PreRender event doesnt fire and focus is maintained.
Is this behaviour normal? What could cause this behaviour?
The ListBox is filled on PageLoad if is not postback, with a default value.
The Listbox is filled on the TextChanged event of a TextBox (the TextBox is used for searching in a DB)
EDIT:
I commented out the PreRender event and the behaviour is not gone. Now I am thinking this may be caused by a PostBack from the TextBox when I remove the focus from it and select an item from the ListBox.
The evidence to this regard: I have a gif that is shown between the beginning and end of a request from the TextBox (loading indicator) and the gif is visible when I select an item from the ListBox for the first time after a render. The second time there is no problem.
Use the AutoPostBack property to specify whether an automatic postback to the server will occur when the TextBox control loses focus. Pressing the ENTER or the TAB key while in the TextBox control is the most common way to change focus.
I have found out why the behaviour I reported happens. Can I somehow make the TextBox not to postback on losing focus? It is aleady posting back on TextChanged and it is enough.
Use the AutoPostBack property to specify whether an automatic postback to the server will occur when the TextBox control loses focus. Pressing the ENTER or the TAB key while in the TextBox control is the most common way to change focus.
I have found out why the behaviour I reported happens. I will now search how to stop the autopostoback on losing focus.

ASP.NET AJAXNumeric Updown control in User control

I have many (around 20 - 30) NumericUpDown controls, that i have added in to user control and they are associated with their appropriate textboxes. These NumericUpDown controls work fine and allow me to adjust the numbers in the textboxes. However, I need to be able to calculate a quantity if items as user changes text box value (withour post back) and need to set it on a label/textbox on the webpage. My problem is that I can't find an event or another way to do those calculations when either the NumericUpDown control is pressed or when the textbox value changes. I've tried:
Using an event of the NumericUpDown control but it seems there are no events that fire when the value is changed
Using the OnTextChanged event of the textbox control, but that will not fire it seems, even when I have the AutoPostback property set to true
Calling a javascript function in the onchange event of the textbox control, but it seems that the onchange event is not called unless the textbox loses focus. The only way the user can change the value is through the NumericUpDown control and thus the textbox never has focus so this event is never fired.
Does anyone have any advice to get this to work? Just a note, I do have this contained in an update panel because I don't want a full page postback when a value in my NumericUpDown control is changed and the percentages are calculated.
Thanks ...
Via this: http://www.asp.net/ajaxlibrary/act_NumericUpDown.ashx
It has a currentChanged event that you can add an event handler for. You can also add an event handler on the textbox, using onblur (when it loses focus) or keypress (as the user types a key). Both event handlers are necessary.
To add the event handler for the AJAX control toolkit control, you add the name of the method to the OnClientCurrentChanged property on the control, or similarly named.

The ListView LayoutCreated Event Is Not Fired After Handling ItemCommand

I am trying to update controls in the of a ListView control after handling the ItemCommand event.
My ListView displays line items of a purchase order in the as html table rows along with a TextBox to enter a new quantity and a Button to update the quantity. My ListView then displays sub-totals, discounts, and a grand total of the line items above in the as html table rows as well. On initial load, I set the values of the controls in the ListView's in the LayoutCreated event handler.
When a new quantity is entered and the button to update is clicked, I handled the event in the ItemCommand event handler. I update the quantity of the specific line item. I then re-bind my ListView to the underlying collection and call DataBind(). The problem is, LayoutCreated is not fired this time around, only on initial load.
My work around is to just pull those controls out of the and address them as static controls, but I like having them inside because my table markup can be fully contained in the and my can show cleanly without having to juggle the static controls' display properties.
Is what I am asking possible? Thank you for any help you can provide.
I'd reccomend handling the DataBound event of the ListView (instead of the LayoutCreated event), and setting the values there. That will get called everytime you re-bind the ListView, as well as when it loads for the first time, which (from your description) is what you want to do.

How to disable listbox's click event

I have a listbox which acts as a list of items. If you click on some item, it's contents are shown in the panel on the right (few textboxes etc.).
I need to have a validation on these controls as all of them are required fields. And I do have it. The problem is that, even when the validators are not valid, user can click the listbox and change active index (that doesn't have impact on the panel on the right, as SelectedIndexChanged isn't fired).
The validators are standard RequiredFieldValidator with their Display property set to "Dynamic". So, what I want is to disallow the user clicking on the listbox and changing the index untill all validators are Valid.
What would be your solution for that? Is that even possible?
Did you try setting ListBox.Enabled = false when you actually do fire off the SelectedIndexChanged, and reenabling when your required fields meet the Page.IsValid requirement to proceed in code execution?

autopackback dropdownlist only if changed using mouse

I would like to perform a postback when the droplistlist selected value changes, but only if it was changed via expanding the downdown and clicking an option, not is the user tabs to the control and uses the arrow keys. The reason for this is simple, keyboard accessibility.
Postbacks are triggered using __doPostBack('uniqueidofcontrol', 'commandname'); so when the list changes value (I believe in onchange event), it posts to the server. You would need to not set autopostback. What you would need to do is tap into the click event (if there is one) and then call __doPostBack(..) method upon that event.
HTH.

Resources