detect changes in the System.Windows.Forms.TabPage - asp.net

I have a System.Windows.Forms.TabControl with collection of System.Windows.Forms.TabPage. Each TabPage is a form where users can enter text values. When a user changes tab, If there are any changes in the current tab; I need to prompt them if they want to save changes made in the current tab. How do I detect if there was a change in the state of current TabPage?

Attach an event handler to each control on the tab page, which sets a flag to indicate that data on the tab page has been changed ("is dirty").
Subsequently, attach an event handler to the Selecting event of your TabControl to show a prompt when you detect that the dirty flag has been set to true for the tab page that is about to be navigated away from.

Related

asp disable button for the whole session

I would like to disable a submit button on a webform like proposed in:
How to disable postback on an asp Button
But the button should stay disabled, even when the user navigates to some other webpage in the application (like admin page) and then navigates back to the original page; (in my case the button is then not disabled anymore). So is there a way that this button stays disabled (for instance until the user logs off from the application) even in such events and for the whole session until the user logs off?
Thank you for your time and effort.
Add a session variable, example Session("btnDisabled") in the event where you want this to happen and check against it every time a page with the button loads.
If session("btnDisabled")=true then btnSomething.enabled=false
then when the user is logged out, you change that variable, either kill it or set it to false.

Browser back button does not move to the previous View

I am using views concept in my asp.net form control.my first view consist of a form to capture user details.when user press continue it will move to the second view.
The problem is ,When user press the back button of the browser from the second view it doesn't move the the previous view instead move to the previous page in the browser history.
I wanted to move to the first view with the existing data in the form,when user press the back button of the browser.
You should perform a full page postback I guess, so that at client end your previous view will be saved in browser's history.

Can we Change the Page.IsPostback property set to false forcefully

I am dynamically loading the web user control into the ajax tab container, and with the help of ActivetabChanged event i am binding the relevant user control into that particular tab.
In each user control i have the data lists contains thousands of records, which i am binding on user control page load event.
I am putting the binding code into !page.IsPostback, now here comes my problem, when ever i changed the tab change event, Page.IsPostback returning true, and datalist does not bind, i force to put the code into !page.IsPostback becaue i have to fire the datalistCommandEvent.
So is there any solution for this problem?
You need to track whether tab has changed or not. Typically, you can store the previous active tab in the view-state and compare with the current active tab in page_load. If the tab has changed then bind the data-list from user-control in the active tab (by invoking public method in your user control that will do the binding of data-list).

Cancel button that does not send form data

Inside an UpdatePanel I have two PlaceHolders which are never visible at the same time. In one PlaceHolder I let the user choose an article to edit and when an article is selected it is displayed in the other PlaceHolder. When this happens is set the visibility of the first one to false and turn the other one on.
Now, when the user edits the article there are some fields and two buttons: one button is labeled "OK" and is used to send the form data to the server and the other button is labeled "Cancel" and is used to. It is only when the user clicks the OK-button that I need to send the form data to the server since this is the only situation where bother to handle it. Therefore, can I let the system know that the it should not send form data when the Cancel-button is clicked?
The issue was brought up because at first, I got a RequestValidation-error from the tinyMCE-component that is used for the body of the article (since it contains HTML), when I clicked the Cancel-button. Now I have turned off RequestValidation for this page and I do the validation manually.
But anyway, can I turn off form-data-sending when the Cancel-button is clicked?
Maybe if you prevent the postback when clicking the Cancel button you'll disable the form-data sending. This could be achieved by subscribing to the OnClientClick event of the button and type return false as a value.

How can controls (buttons) be set in a ModalPopup Extender panel that do NOT close the panel?

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.

Resources