Validating Tabstrip with Multipage Control

V

vikaskuk

hi all,


i am using tabstrip with multipage control in asp.net.
i have put some textboxes on the first tab.
my requirement is that whenever user makes some changes in any of
textbox and moves to next tab without saving this data he should get
alert message and should be stopped on current tab itself.


For this i have written a javascript function and called it
onSelectedIndexChange event.
The Problem is that the function gives the alert message but not able
to restrict the user to current tab.


As soon as alert comes at the same time control of next tabs gets
visible.
i just want not to allow user to change the tab if anything is unsaved
on current page.


Thanx in Advance
Vikas
 
G

Guest

If all controls use viewstate, the data should be saved for each control
(provided you are not using Page_Load as a catch all, as is oft done). Then,
you can use code behind to force the user back to the tab in question and
create a JavaScript popup from CodeBehind, either by attaching the JavaScript
code block to a container (panel, for example) or emitting through a control
on the page using the .NET script emission methods.

There is a possibility of controlling this on the client side, but you will
have to short circuit the tab strip to do so, as it emits its own JavaScript
(view source in your browser to see what I mean). To short circuit, you may
end up having to inherit and override the tabstrip. Not sure this is the best
use of time, as there is a way to handle the issue on the server side.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
R

Rachel Suddeth

Unfortunately, that seems to be very difficult with tabs. I had the same
issue with Windows Forms TabControl, and it kills me because I did solve it,
but it was very complicated, and I have lost the solution. There is (in the
Forms version, at least) a Validating event on the tab pages that sounds
like it would be perfect because there's a Cancel in the EventArgs, but it
turns out to be useless. It would fire when I didn't want it to, and not
fire when I did want it... apparently its idea of when it needed validation
had nothing to do with whether the controls on it were edited. I think it
reacted instead to whether controls had been added or removed from its
ControlCollection...

So I will keep a watch on this in hopes that someone has a simpler and
better solution. Otherwise, I'll have to re-do the complicated one that
involved keeping track of the old SelectedIndex, changing back, keeping
information about why the SelectedIndex had changed, so that if it was a
change-back it would display the Alert instead of the usual stuff (or maybe
on top of the usual stuff?), and then chaning AGAIN if they really wanted
to.... phew! There must be an easier way...

Rachel
 
V

vikaskuk

Thanx Gregory for your suggestion, but the problem is still there.

The method suggested by you redirects the user from codebehined to
unsaved tab but before redirecting it displays the html part of the tab
to which user clicked means when user clicks on new tab , controls of
new tab displays up but due to redirection it return back to unsaved
tab.
Is there any method available through which i can restrict user to
unsaved tab means the controls of new tab doesn't get displayed at all.

Vikas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top