asp:button firing and not supposed to ShowModalDialog

N

needin4mation

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.
 
N

needin4mation

I ended up using ValidatorEnable(myBtnOpeningTheShowModalDialog,true);

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.
 
S

sreejith.ram

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
 
N

needin4mation

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.
 

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

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top