473,394 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

asp:button firing and not supposed to ShowModalDialog

Hi, I have an asp:button that has a ShowModalDialog script attribute
added to it.

When the ShowModalDialog opens the user is supposed to select some data
which is then sent back to the calling .aspx page and that data sent
back is placed in a hidden textbox for processing when the form posts
back from the asp:button (the same button that called the
ShowModalDialog windows, calls the window and then postsback). This
works fine.
If the showmodaldialog opens and the user closes the window without
selecting any data to send back to the parent form, then the asp:button
has a RequiredFieldValidator on the hidden textbox to keep the button
from doing a postback. However, the button posts back anyway and when
the form returns I see the field validator has fired. Everything is
set to runat=server.

Incidently, I should say the field is visible at the moment, but it
will be hidden in production.

How can I keep the asp:button from posting back when the hidden field
is not populated? Thank you.

Nov 19 '05 #1
3 1965
I ended up using ValidatorEnable(myBtnOpeningTheShowModalDialog,tru e);

I also found that when the validator worked that they button
disappeared! I had to put the style.visiblity="visible"; after my call
to the ValidatorEnable. I can find no code that turns the button
hidden or invisible in my source or compiled code.

Nov 19 '05 #2
I beleive, you are accessing the Hidden text Box in parent page from
the popup using a code similar to window.parent.Form(0)...........
Instead, try using the returnValue to get the value from popup..

window.returnValue = "datauser enetered";

the syntax in parent page is

var strValue = window.showModalDialog(url,prams etc etc);

if(strValue != 'undefined' && strValue != null)
{
// assign to hidden column and continue process and post back
}
else
{
return(false); //this would prevent from the form being posted.
}

When the user close the popup without selction, the strValue will be
either 'undefined' or null or "" .. I am not being able to recall which
one of it.

HTH

Nov 19 '05 #3
It is null, but even though it has this code return false, it fired.
That was the cause of the OP. Even though my code has return false it
fires.

My actual code is var retval = showModalDialog(....)
if (retval.myid !=null)
do stuff
else
return false.

in the else I had to manually set the ValidatorEnable to true to stop
the PostBack.

Nov 19 '05 #4

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

Similar topics

0
by: Maziar Aflatoun | last post by:
Hi everyone, I have the following shopping cart (basket view). However, Delete button in my datagrid doesn't fire any events. Does anyone know why? (It's a user web control) <%@ Control...
4
by: esoroka | last post by:
Hello, Trying to run a script what start ASP button: document.Form1.all.click(); It is work one time only. Next script ignore it. Where can be problem??? A full script is as follows:
1
by: Novice | last post by:
Hi all, as you can see from the subject, I'm try to use an asp:button to create a new browser window and output contents to new window But default if I do the Response.Write("..." The output...
4
by: z. f. | last post by:
Hi, I'm having an aspx page with a server form. i have a grid with a delete button and below the grid, another area with inputs for inserting new values and an "add" button for submiting the...
7
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the...
2
by: Weston Weems | last post by:
Hello... I've got a solution with 7 projects... the problem I am having specifically is that I've got a simple asp:button on a simple usercontrol. I am making sure its not stupid vs.net...
8
by: tatemononai | last post by:
I had a beautiful script that was running, well, just beautifully. But then I decided to take a button that fired an event and place it inside a <asp:table. The event WILL NOT FIRE INSIDE THE...
5
by: csgraham74 | last post by:
Hi guys, I posted regarding this issue the other day but i still dont have an answer to my problem. Basically i have imported asp.net pages from dreamweaver into visual studio. Ive added a...
1
by: mazdotnet | last post by:
Hi all, I'm really stuck trying to figure the following out. I have been working on a shopping portal where you can select products from a list inside a repeater on the bottom of the page and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.