http://binaryjack.com/userControl.aspx
Each record is displayed using a user control. I have the delete button embedded in the user control.
Recreate Problem: click the first DELETE button, the last row gets deleted; after this I have to click the delete button (any of them) twice to make it work.
Is it bad practice to use a User Control (combined with a placeholder) to display a bunch of records? I query to get all records and then use a Foreach loop to populate each User Control and insert each UC into the placeholder.
Why does the Delete button not respond correctly?
Without seeing your code it is tough to say. However, it appears to be a refresh issue. If you hit delete then hit refresh, the record is gone. Check how you are refreshing the data and you'll find the issue.
Related
After I have successfully added a record in a subform, I have to manually click on the next record and back to view the added record in a subform that contains a query in datasheet view. I've looked up requery and can't seem to get it to work. I want the new record to show immediately in the query as soon as the user press the "Add Record" button I created. Any guidance would be appreciated.
I just used the built in command button to add a record. I also tried using the built in command button to "save record". I'm guessing I need something to trigger an "after update" or a requery; but do I put it on the command button or where?
That's because you add the record via an SQL insert command to the table behind the subform. Then you need to refresh the subform.
It is faster and smarter to add the record to the RecordsetClone of the subform. This way, no update is needed.
I know there's a lot of information out there about how disabling ViewState will not prevent textboxes from persisting values across refreshes/postbacks. What I can't fins is information about how to circumvent this behavior.
Here's why I need to do this. I have a form that updates a db via AJAX. Every time a user changes a field, the db is updated immediately. Because of this, there's no reason to store values anywhere but the database.
Consider the following scenario.
User loads the page, textbox FirstName has a value of "Bob."
User changes first name to "Dave." (Database updates)
User clicks the refresh button.
We'd expect the FirstName box to now have the value of "Dave," but instead it shows "Bob." So how to force ASP to load the values from the db?
User clicks the refresh button.
On this step you'd re-read the data from the database and forcibly populate the controls with that data. If all of the "events" from the page are in fact handled by AJAX requests, then it sounds like the only two meaningful "WebForms events" are Page_Load and the Click handler for the "refresh" button. One of those two events should re-populate the controls from the database.
(Or is there no "refresh" button and the user is just reloading the page via browser functionality? In which case Page_Load should just always populate the controls from the database in this scenario.)
It seems the problem I was encountering had to do with creating and populating controls in during the correct page events. Fixed this by creating controls in Page_Init, and populating them in Page_Load.
In a ASP.NET application I have a paging RadGrid which shows up textbox in each row. Outside the grid, there is an OK button to save the content of all the textbox. If user changes text in any one or more of the textbox and without clicking on the "OK" button, tries to move to a different page number (of the grid by clicking on the page number), he should be prompted for confirmation of save or cancel the changes.
I am guessing that one can write a Javascript function which would look for any form input control (textbox in my case) and detect changes and If there are changes, would prompt the user. However, I am not sure where I can call this function from? Any suggestion on this or a better way to achieve this would be appreciated.
I am using RadGrid but I guess this should be applicable to GridView as well.
I am not sure if this will help exactly but it might at least give you an idea:http://www.codeproject.com/KB/ajax/ajaxdirtypanelextender.aspx
Here's the situation.
When a user is editing a given piece of data, they're allowed to add messages/comments. These are stored as child records in a SQL database. Clicking on the Add Message button brings up a panel (pnlMessage) courtesy of the AJAX ModalPopup Extender. This takes some input and, when the "Send Message" button in the panel is clicked (I learned the hard way to NOT make that the 'OkButton' property), the message is stored in the database and an email is sent to the intended recipients. No problem there.
However, I need to be able to allow the user to add new email addresses (so long as they are registered in our database). I have another ModalPopup / panel combo (pnlSearch) that's tied to a button on the previous panel (pnlMessage).
The user is supposed to be able to add an email or click on a search button to populate a list to choose from.
The pop-up panel (pnlSearch) comes up just fine, but clicking the "Lookup" button (which instigates the search and returns a collection of records that the user is supposed to pick from) closes the panel.
Previously, I ran into the problem of having the Button.Click event never firing when I put the Button into the "OkControlID" property (the CancelControlID works fine since I don't want to do anything). Removing the "OkControlID=Button" line allowed it to work perfectly with the Button.Click event firing as expected.
So now I have the Search panel with a button for "OK" and a button for "Search" - but the panel should stay up and visible after the Search.Click does it's thing. Am I missing some property that basically says "don't close the panel when this button is clicked"? Of course, if I bring up the panel again in the same session, the results from the previous effort are there (the search results).
I'm trying to avoid having to go to javascript as there isn't much, if any, of that experience available to support this.
Help!
Thanks in advance.
You can put the Search panel and the Search button inside of an UpdatePanel. Anything inside of the UpdatePanel will be able to post back without closing the popup. Be sure not to put the buttton that is supposed to close the popup inside of the UpdatePanel.
I have a page where I submit some data, and return to the original form with a "Save Successful" message. However, the user would like the ability to return to the previous page they were at (which contains search results) by clicking the browser's "Back" button. However, due to the postback, when they click the "Back" button they do not go to the previous page ,they simply go to the same page (but at its previous state). I read that enabling SmartNavigation will take care of this issue (postbacks appearing in the history) however, it has been deprecated. What's the "new" best practice?
*Edit - I added a ScriptManager control, and wrapped the buttons in an UpdatePanel, however now I'm receiving the following error:
Type 'System.Web.UI.UpdatePanel' does not have a public property named 'Button'
Am I missing a reference?
*Disregard the above edit, I simply forgot to add the < ContentTemplate > section to the UpdatePanel :P
If you put your "Save" button in an UpdatePanel, the postback will not show in the users history.
I would avoid if possible. A better solution would be to have a button that just returns them to their search results on the "Save Successful" screen.
The problem with the ajaxy saving and such is that you violate the "Back" rules that users expect. This user might want the Back button to go back to the Search page, but other users might expect that clicking Back would return them to the Add/Update page. So if another user tries to update something, clicks save, and then "woops, i forgot something on the update", they'll click back, and now they're at search results, instead of the expected Update page.