So I'm amending someone else's code, and they've used a data-bound Accordion control. I need to disable the Accordion functionality so that the top item is expanded and the rest are just minimized and kept that way.
Also is there any way to put a class on the final item?
Thanks a lot in advance.
The easiest thing might be to replace the Accordion control with a Repeater that is styled to look like the current Accordion.
But, to attempt to answer your question(s):
Create a OnItemCommand event handler that just sets the SelectedIndex to 0. That way the user can't open any other items in the Accordion.
As far as the style of the final item, you'll have to create a OnItemDataBound event handler that knows how may items are in your collection, and then count the items that it has bound. When the method is binding an item with the index that matches the size of the collection you just set the item's CssClass to be the class for the final item. (This same technique should also work if you were to replace the Accordion with another control.)
Check the first answer for the question 'How do I bind an ASP.net ajax AccordionPane to an XMLDatasource?' for a example of the ItemDataBound event handler.
Related
I have a Master Page which contains a Dropdown, based on the Drop down selection I change the language of the entire site. Now, in one of the child pages I am using a repeater and binding some data to it. I am also using the ItemDataBound event of the repeater as well (I require a tooltip for one of the cells). I am trying to figure out a way when the master page Dropdown value is changed I should also fire the ItemDataBound event so that the data is displayed in the correct language. I am guessing it has to do something with playing around certain events. Any ideas or feedback will be appreciated.
ItemDataBound is only fired when data is bound to the control. You would have to rebind the data to the repeater in order for its ItemDataBound events to fire again.
Your other option is to write additional code to loop through all of the items in your repeater and perform the actions you usually perform in ItemDataBound.
I have few Ext.NET ComboBox controls on a Web Form. Selecting an item from the first fires the ValueChanged event to populate the second, and so on.
Except Force Selection property, I have not altered other properties of the ComboBox control.
I am experiencing odd behavior of Combo Box controls. As all controls get filled via AJAX request, I find it difficult to set focus on any control. As soon as I bring focus on any control, the cursor disappears after it gets filled.
Secondly, one of the ComboBox is not permitting me to select an item from the list. Even if I try to select an item, it automatically brings back the default item back, which is actually a sixth item in the list.
I double checked the queries and there is no way through which sixth item should get selected.
If I try to open the DropDown list using mouse, it opens for few seconds and collapses automatically.
Is there any way to fix these strange issue? Any other third-party open-source control?
I guess that combos are rebinded in each ajax requests
I suggest to rebind combos in Select direct event handler
Also see the following sample
http://examples1.ext.net/#/Form/ComboBox/Ajax_Linked_Combos/
I have a Telerik RadComboBox with an item template. In the item template I have an ASP checkbox. I have a client onclick handler for the checkbox and in that I want to get the telerik RadComboBoxItem object and from that get the RadComboBox object. I can get the DOM elements by of the item by from checkbox.parentNode.parentNode. Telerik has a method to get the DOM element from a RadComboBoxItem, but how do I get the item from the DOM element?
Thanks,
Brian
Even with templates, you can set the text and value fields to bind I believe. With that said, if you store the text in the checkbox, you should be able to get the master RadComboBox and find it with findItemByText method... (mentioned here: http://www.telerik.com/help/aspnet/combobox/comboclsideobject.html).
You could also look at the HTML to see if the DIV for the combo box item has a unique ID; if it does, you could get the ID and use $find(id) to return you the item too. I don't remember this if it does or not.
Some ideas, HTH
Problem: Content Page with Wizard Control with UpdatePanel and Placeholder. Above the UpdatePanel is a DropDownList. I need to display different input controls below the drop-down list when the user changes the selection in the drop-down list. When the user clicks 'Next' on the wizard control, I need to be able to get the data out of those dynamic controls as well.
I know all the dynamic controls have to be created in the OnInit method in order to get the data back from those controls during the postback. However, when the drop-down list's SelectedIndexChanged event is fired, the OnInit method is called... then the PageLoad... and finally the handler for the SelectedIndexChanged event is called. ViewState hasn't been restored until well after the OnInit & PageLoad methods have been called, so there is no way to know what the user chose in the list box at the time OnInit is called... which exactly when I'm required to create the dynamic controls.
So... how do you solve this problem? Do you just have to write the entire page, or most of it, using JavaScript?
Thanks in advance.
I tend to use an old school method for this type of requirement. I would write all of the controls that are needed in the update panel, with their Visible property set to false. Then, on post back read the drop down's state and set the approperate controls Visible property to true. This way there is no "dynamic" controls, and due to the fact that controls whose Visible property is false are not rendered, they are not downloaded until the user should see them.
you can also use an asp:hiddenfield and set the value to a case var you mentally create. then run a small jQuery script on top to look at
$(document).on("change", "#ddlSelector", setControls);
then just make a function, for instance:
function setControls(event) {
event.preventDefault();
var selector = hiddenfield.val();
}
then any item to show/hide can be done with getting the tag:
$("#elementName").css("display", "inline");
or display, none to hide.
I used this at work because at times you need to change without firing the postback, but still collect data when they engage the form.
I typically avoid jQuery for many events for strength of code and security, but DOM element manipulation can be much easier at times with jQuery.
I have an "action" column in my repeater which shows actions a user can select for an item. The column contains ASP.NET HyperLink or LinkButton controls. Some actions are based on whether a user is in a role, which I determine programatically. I'm struggling with the best way to dynamically generate this column when I populate the repeater. Now I am assigning in-line code to the Visible property of each control, but I feel that is sloppy and not very straight forward. Would I be better served using a PlaceHolder control and populating that at runtime? What kind of methods do other people use for situations such as this?
The "normal" way to apply any sort of dynamic rendering to a Template based control such as the Repeater is to handle the ItemCreated or ItemDataBound events.
In your particular case, you could check appropriate conditions within that event handler and toggle the visibility of the relevant "Action" column.
Also, see this question where Ian Quigley posted a code snippet that should serve as a good example for you. It may also help to read my own answer which shows how to use visibility toggling in inline code.