I am trying to manipulate (move up and down, enable/disable and launch a form) child controls inside a panel control. However I am unable to get the id of the child control on which the click event occurs.
To illustrate, I am trying to create similar functionality as is available. I am trying to create the up-down buttons that you see in the image at http://i34.tinypic.com/2gugio6.jpg
Any help/pointers are appreciated.
Thanks
I am unable to get the id of the child control on which the click event occurs.
Use event.currentTarget inside the event handler to access the child control in which the event occurred.
It would help if you post some code. Since I don't know the details, I am giving you the most basic answer.
For example, if you want id of a button in your code, you specify that id in the mxml. So,
<mx:Button label="myButton" id="btn1"/>
Now, say in your script you want to add an event listener here, you access this as
btn1.addEventListener ....
Now, lets say you want to access not a button or some independent control, but you want to access elements inside a list, there are several ways. I am presuming you would like to access the selected item. You simply say
list1.selectedItem
As I said, it would help if you post your code and specify a more precise problem.
Related
Where can I find the complete list of attributes for a control? If I wanted to use textbox control on my asp.net application, where can I find the complete list of attributes associated with it? I know some of the them can be found in the properties area in the IDE. But the properties area did not have the "OnTextChanged" attribute listed.
When you click on a web control, if you have the properties window open, then you will see it's properties, which contain the attributes of a web control. Another way is to click on the control and the right click and select properties.
By the way the OnTextChanged is an event, which you can associate it with a method, when this event happens.
OnTextChange="TextBoxText_Changed"
The TextBoxText_Changed would be a server side method, which will reside in your code behind class. In this method you will declare, what you want to happen, when this event is triggered,
![Properties][1]
[1]: http://i.stack.imgur.com/iUUqZ.png
go to property window click on event icon and you can see all events associated to text box.
You can look it up on the MSDN documentation page:
http://msdn.microsoft.com/en-us/library/System.Web.UI.WebControls.TextBox(v=vs.110).aspx
I am attempting to use jqGrid ASP.NET for the first time and I'm having an issue with properly using a parent and child grid on my form.
Scenario: On my form I have two grids, one a parent that displays product information, and a second child grid that is used for editing a collection of prices for the product in the parent row. When a user clicks the plus sign in a parent row, the OnDataRequesting event is handled and I load the child grid with that product's prices. When the user clicks a price in the child grid, I use ClientSideEvents RowSelect and the server side RowEditing event to perform inline editing.
All of this was fairly trivial to set up and works great. Where I'm having an issue is that I'd like the selected row in the parent grid to act like a context for the rest of the page, i.e. the rest of the page displays information related to the product selected (charts, graphs, etc). For this I set up an event handler for the OnRowSelecting event and then trap the RowKey from the event args. That works great. However... the unintended side effect of setting up that handler is that once a user selects a row in the child grid to edit, the OnRowSelecting event fires in the parent, the page posts back, and when the page reloads the child grid is closed and the attempted edit is thwarted.
What I would like to know is, is there any built in way to handle this sort of scenario either through the client side jqGrid library or the Trirand.Web library? Or will I need to write some custom script to either send the selected parent row asynchronously or possibly trap the expanded child grid and attempt to reopen it once the post back is complete? Thanks.
I thought I'd brush off the tumbleweeds here and inject the answer I finally received from Trirand's support. As of the time of this writing, you can't do this. If you handle the OnRowSelecting event, you cannot use an editable child grid as they built it to specifically fire the parent's OnRowSelecting event anytime you select a row in a child grid.
This is a little difficult to explain so please bear with me.
I have a procedure that is generating some radio buttons and assigning a CheckedChanged postback event based on the level being passed through (up to 4 levels). When the first level is checked (radio button selected) the postback event rb_CheckChanged00() is called and a check is done to see if this item has any children, if it does, it will create more radio buttons and assign rb_CheckChanged01 to the CheckChanged event for these - This part is working fine.
The issue I have is when I select the second Radio Button that has been created (the child), it doesn't seem to go to the post back event at all. The page is posting back when I click on it but everything resets because it won't go into rb_CheckChanged01.
I know this info is quite vague but I am hoping someone has an idea on how the post back event works and if I am somehow using it incorrectly.
Using: ASP.NET 2.0, IIS7
Thanks.
Most of the time when the dynamically created control's events are not fired, it's because the controls are 'reset' upon postback.
To make sure the same controls get created each and every time make sure that the control's IDs are set to the same values each and every time, before the ViewState is loaded. This way, when the control is added to the control collection of the page, once the ViewState is loaded, it'll persist it's properties. (just to describe what happens, in a nutshell)
One of the best articles I've read on this topic is this one. Make sure you read it, to fully understand what's happening in the background.
Looks like the child RBs are cleaned before they are able to trigger the event. From my personal experience, it's best to keep track of those dynamically generated objects, and regenerate them in every postback. The events will start to trigger :)
Your controls and events are not registered in the ViewState because dynamic controls need to be loaded in the Page_Init. Because they're not persisted in the ViewState, they won't be registered with events. A similar question:
Problem with dynamic controls in .NET
Only 1 thing can cause this, you create the rb's on page_load and don't add them to a List<> or something similar and that object to Session. What you need to do is when you create the items, Add them to a List and add that list to Session["RadioButtons"] and if the Page.IsPostBack is true, load your controls one by one from your list which is kept in your session to your page.
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.
This is what I'm doing: Using jquery, I'm popping up a "form" over the page that lets the user search for branches of the company and select the one they want. When the form pops up, they can type in a textbox, and it will do AJAX requests back to the server to return the top n results for what they've entered, and those results will be put into a list for them. I want the user to be able to select one by clicking a link that says "select" or something, and at that point I want it to do a PostBack have the Branch Selector control that this is in change it's SelectedBranch property to the newly selected branch. I've got this all working right now with a hard coded list of LinkButtons, but how do I do the same thing with a dynamic list of links inserted with jquery?
Look at the HTML that gets emitted for your hard coded LinkButtons. You'll see that each one calls the JavaScript __doPostBack function when clicked. I believe this function takes two arguments: a control ID and an extra command argument you can use for your own purposes.
I would suggest adding a single control to the page whose only job is handling events for the dynamic links. Then, when you are creating the links with jquery, make each one call __doPostBack, passing the event handling control's ID for the first argument and some other string for the second argument that identifies which link was clicked. In the Click event for the handling control, look at the second argument value and do what you need to do.
The short answer is... you don't.
ASP.NET relies on the Viewstate for the current state of the controls, including items in a DropDownList or similar control. Dynamically updating a list on the client will not modify the viewstate, so will not be available on the back end.
The general workaround for this is to just add a hidden field which updates/stores the current selection via js on the client side. Then read it from this field on the backend rather than List.SelectedValue.