471,357 Members | 1,086 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

Validating Tabstrip with Multipage Control

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

Jul 21 '05 #1
3 1838
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!
***************************

"vi******@yahoo.com" wrote:
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

Jul 21 '05 #2
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

<vi******@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
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

Jul 21 '05 #3
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

Cowboy (Gregory A. Beamer) - MVP wrote:
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!
***************************

"vi******@yahoo.com" wrote:
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


Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by floater55 | last post: by
1 post views Thread by szabelin | last post: by
reply views Thread by Greg Taylor | last post: by
reply views Thread by sri_san | last post: by
9 posts views Thread by Mardy | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.