Reset a view in an asp.net MultiView - c#

I'm using an asp.net MultiView control with 2 Views inside.
First view has a "create" button to create new customer. Clicking the "create" button will display the 2nd View of the MultiView which allows to enter customer information.
Second view has a "return" button to return back to the 1st view.
The problem is: after creating the first customer, clicking the "create" button again will render the 2nd view with first customer's information already entered.
Is there a way to reset 2nd view to its default state whenever the "create" button is clicked?
Perhaps, clearing out the viewstate?
Currently I'm using a recursive method to clear out all the inputs (textbox, radiobutton, dropdownlist, etc.). I just want to know if there's a cleaner/better way.
Thanks

Easiest way to do it is to have the return button do a response.redirect to the same page. It won't be terribly inefficient and you won't wave to manually reset anything.

You could possibly use OnClientClick on btnReturn to simulate a click on a hidden <input type="reset"> button.

Related

Is it possible (or something similar) to disable a button control from a calendar control when the selection is changed on the client side?

I'm not sure if this is possible but I'm looking for a solution that would give a similar effect. I have a calendar control on an asp.net (C#) page along with a button.
Here is some background as to how the page works: When the user selects a date range, there is a post back that shows data and also populates a few drop down boxes with data relevant to the selected date ranges. The dropdown boxes are used to filter the data, for example, the user could choose a specific customer to view data for. After the user selects filters from the drop down boxes, they would click the button to update the page with the filtered data. Alternatively, if they did not select a date and the button is clicked, the selected date range is assumed to be this week. The button is needed because we would prefer not to do multiple database calls if the user wants to use more than one filter from the dropdowns.
With that said, I want to be able to prevent each of these controls from calling another post back if there is already one in progress for the other control. I've seen disabling a button by doing this:
<asp:Button ID = "ShowDataButton" runat="server"
OnClientClick="this.disabled = true;"
UseSubmitBehavior = "false"
onclick="ShowDataButton_Click"
Text = "Show Data"/>
Is there a similar property for a Calendar control that would allow me to disable the button control? Something like, OnClientSelectionChanged = "ShowDataButton.disabled = true;" From what I've researched so far, I'm not too hopeful that this exists. If it doesn't, is there another way that I could accomplish something similar? When I try to add ShowDataButton.Enabled = false; to the OnSelectionChanged event method in the code behind, the button doesn't get disabled until after the postback is finished, which I should have expected. Without something like this occurring, the calendar control ends up returning DateTime.MinValue if the user selects a date and then immediately clicks the button (as the post back takes a few seconds to complete). Any ideas or suggestions would be greatly appreciated.
Your OnClientClick property should actually call a javascript client-side, and then in the javascript you would need to do any actions you desire (eg disable a button, change its style to hide it, etc)

Get the Rad button that were clicked after Post Back

I'm using telerik Grid which has a command button that adds new row/record or another command button that edits selected row/record.
Each grid is inside a twitter bootstrap tab content (Yes, I didn't use telerik tab). What is happening is that when one of buttons that I mentioned above clicked, I expect the tab that contains that button be active at page load.
So is there anyway to get that button so I can use it to activate the proper tab? (ID of that button is enough for me, I will do the rest with jQuery)
Every control that posts back, in an ASP.NET web forms world, sets the __EVENTTARGET and __EVENTARGUMENT (if there is an argument) form values. The __EVENTTARGET form variable has the client ID of the button, so that might be the optimal way. If it's within the grid, I'm not sure, but the __EVENTTARGET may either be the button or grid ID.

passing data from Ajax Modal popup extender to a textbox on the asp.net page

I have a Ajax modal popup that displays a set of options for the user. On submit button click event on the ajax modal popup, i need to pass the user selected data back to a text box on the user control (which has the modal pop up) on the calling page.
Structure/flow is as follows. There is a page and two user controls. One is a search control that has another user control that contains the user options. The master page has the search user control. When the user chooses an option in a dropdownlist in the search control, it does a mpe.Show of the user control with options. User makes his selections and hit submit button. In the button click event in the popup, i delegate an event back to the search user control which tries to set the value in one of its text boxes. Everything is going fine until this step and i can see the value but the text box never changes. It seems like the user control is already rendered and the changes are ignored. Any idea how I can get around this?
In short, how to get back the data to a control from an Ajax modal popup.
Use jquery - when the user clicks a button on the modal - use jquery to set the value field to be the data that the user has selected.
e.g.
$('#modalButton').click(function() {
var userData = $('#tbUserData').val();
$('#textBoxElsewhere').val(userData);
});
for anybody's future reference, i did a work around for this. What was happening is that, on the final button click postback, the page/parent user control load events run first and then the button click event.. so the changes that were being made in the button click event did not make it back to the parent user control on the page.. i had to add a middle step to display the user selections for approval and force the user to hit a final confirmation hit. On that post back, the changes were already available for the parent user control, and not have to wait for the button click event to trigger to grab the data. I'm sure there is a better way to do this but this is what I could come up with.

Button in the Header Template of Repeater

I have an ASP.NET repeater which contains grid view and a panel which contains save button.
the repeater displays grid and save button for each employee..
if there are 5 employees then 5 grids and 5 save button will be displayed.
Now i want to move the save button to Header.. in that case i'll have only one save button for all the grids..
if any grid is modified and i click the Save button, how can we know which grid is edited.
pls help.
If the grids don't post back, i'm not sure it's possible to know which grid was edited. You could add an hidden field to the page (asp:HiddenField) and modify the value using javascript and then check the hidden value when the save button is pressed. Also, why do you have a save button? The gridview has full support for CRUD (Create/Read/Update/Delete) operations.
i think you can use "for each" to loop throw all items in the repeater
and you can check if there is any change in the item then save it if not then leave it and move to the next item.

How do I override the OK/Cancel button of new list item form in SharePoint?

I have a custom list in SharePoint, and I want to override the OK/Cancel buttons that are in the New Item form (The form displayed when you click "New" in the default view of the list).
I want the saving logic to remain intact, but I just want to change the default page it redirects to, ideally, to a whole separate page on the site that's not a view of the list.
Is there any way I can achieve this?
Thanks in advance!
Depending on what you are looking for, a programmatic approach would be to write an Event Handler and after the ItemUpdated or ItemAdded event redirect to the location you want.
For more information
Ted Pattison MSDN Article on Event Handlers
Yes you can do that. [I guessing you are working with list]
Navigate to NewForm.aspx of that particular list
Open it for editing
Go to Data view Controls and drop Form action control to the form
Add Commit and navigate to page actions in sequence.

Categories