473,506 Members | 16,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

do not want page to reload if selected index of control is 0

Hi I have a page that pops up a warning box if a selection is not made, see
below.
<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
window.alert("Missing Arrival Time");
Anyhow the btn_submit will post back to the server and reload the page.
Just wondering if anyone knows how to prevent this if the
drp_dn_arriv.selected index = 0? This is a dropdown box and when the index
is 0 it means a selection has not been made. Thanks.
--
Paul G
Software engineer.
Nov 19 '05 #1
4 1799
Try returning "false" from your handler when you want postback to be
canceled.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
Hi I have a page that pops up a warning box if a selection is not made, see below.
<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
window.alert("Missing Arrival Time");
Anyhow the btn_submit will post back to the server and reload the page.
Just wondering if anyone knows how to prevent this if the
drp_dn_arriv.selected index = 0? This is a dropdown box and when the index is 0 it means a selection has not been made. Thanks.
--
Paul G
Software engineer.

Nov 19 '05 #2
Hi thanks for the information, just wondering is this done in Java script,
and what would it look like?
--
Paul G
Software engineer.
"Peter Rilling" wrote:
Try returning "false" from your handler when you want postback to be
canceled.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
Hi I have a page that pops up a warning box if a selection is not made,

see
below.
<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
window.alert("Missing Arrival Time");
Anyhow the btn_submit will post back to the server and reload the page.
Just wondering if anyone knows how to prevent this if the
drp_dn_arriv.selected index = 0? This is a dropdown box and when the

index
is 0 it means a selection has not been made. Thanks.
--
Paul G
Software engineer.


Nov 19 '05 #3
Yes, in JavaScript.

<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
{
window.alert("Missing Arrival Time");
---> return false; <---
}
</script>

I have not done this within a handler defined in a script block, usually
just from a function or something, but this might work for you.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.com...
Hi thanks for the information, just wondering is this done in Java script,
and what would it look like?
--
Paul G
Software engineer.
"Peter Rilling" wrote:
Try returning "false" from your handler when you want postback to be
canceled.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
Hi I have a page that pops up a warning box if a selection is not made,
see
below.
<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
window.alert("Missing Arrival Time");
Anyhow the btn_submit will post back to the server and reload the

page. Just wondering if anyone knows how to prevent this if the
drp_dn_arriv.selected index = 0? This is a dropdown box and when the

index
is 0 it means a selection has not been made. Thanks.
--
Paul G
Software engineer.


Nov 19 '05 #4
Hi thanks for the additional information. It works!
I have 4 controls that must have valid entries before the postback takes
place,
also have a popup window for each on missing.
</script>
<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
window.alert("Missing Arrival Time");
if(document.Form1.drp_dn_dtype.selectedIndex==0)
window.alert("Missing Data Type");
if(document.Form1.lstbx_dest.selectedIndex==0)
window.alert("Missing Destination");
if(document.Form1.dr_lst_event.selectedIndex==0)
window.alert("Missing Event");
if ((document.Form1.drp_dn_arriv.selectedIndex!=0) &&
(document.Form1.drp_dn_dtype.selectedIndex!=0) &&
(document.Form1.lstbx_dest.selectedIndex!=0) &&
(document.Form1.dr_lst_event.selectedIndex!=0))
{
return true;
}
else
{
return false;
}
</script>
--
Paul G
Software engineer.
"Peter Rilling" wrote:
Yes, in JavaScript.

<script language="javascript" event="onclick" for="btn_submit">
if(document.Form1.drp_dn_arriv.selectedIndex==0)
{
window.alert("Missing Arrival Time");
---> return false; <---
}
</script>

I have not done this within a handler defined in a script block, usually
just from a function or something, but this might work for you.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:66**********************************@microsof t.com...
Hi thanks for the information, just wondering is this done in Java script,
and what would it look like?
--
Paul G
Software engineer.
"Peter Rilling" wrote:
Try returning "false" from your handler when you want postback to be
canceled.

"Paul" <Pa**@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
> Hi I have a page that pops up a warning box if a selection is not made, see
> below.
> <script language="javascript" event="onclick" for="btn_submit">
> if(document.Form1.drp_dn_arriv.selectedIndex==0)
> window.alert("Missing Arrival Time");
> Anyhow the btn_submit will post back to the server and reload the page. > Just wondering if anyone knows how to prevent this if the
> drp_dn_arriv.selected index = 0? This is a dropdown box and when the
index
> is 0 it means a selection has not been made. Thanks.
> --
> Paul G
> Software engineer.


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
8520
by: Dominic | last post by:
I have a home page on an intranet called default.asp I just type in the server name to take me to the default page http://server. The home page has an anchor name tag: <A name="fred">Freds Info</A>...
3
3024
by: Grober | last post by:
How can I stop the asp page from reloading when I e.g. hit a button or change the selected index of a dropdownlist to update another control on the page? The updating part works fine, when I select...
6
16032
by: DotNetGruven | last post by:
I've got a page that does a search... There is an ImageButton on it that allows the user to reset the search. The Click Handler for the button clears out the Data and then redirects to the same...
0
1279
by: seven | last post by:
I have a base page with an HTMLForm object (added to the base page control heiarchy during Init). In the design of pages derived from this base page, I can choose to create controls and add them...
8
2183
by: Radx | last post by:
Here in my web application, I have a data entry page with serval controls. Some of the controls have autopostback is set true. But the problem is when two or more people are entering data at the...
3
3139
by: dshan | last post by:
Hi all, I can't find an answer to my quesiton anywhere. Given a drop-down list with USA states and other text fields I pass this information for further processing via PHP. If any of the...
9
3164
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
2
3334
by: bbsbob | last post by:
Hello, I'm still using the Framework v1.1. Forgive me, I'm working on a legacy application. I'm using 2 iFrame sections with 2 aspx pages, i.e. 1.aspx (left) and 2.aspx (right) In 1.appx page,...
1
2485
by: jobs | last post by:
Is there a way or an attribute I can set so that the selected page number in paging is a different color or is underlined? perhaps it's my skin or css, but In my gridviews I can't tell what page we...
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.