showmodaldialog issues

  • Thread starter Thread starter luna
  • Start date Start date
L

luna

im playing around with showmodeldialog, and the child window isnt returning
the variable to the parent

in the parent i have

Button2.Attributes.Add("onclick", "var strReturn;
strReturn=window.showModalDialog('test.aspx',null,'status:no;dialogWidth:370px;dialogHeight:220px;dialogHide:true;help:no;scroll:no');if
(strReturn != null) document.getElementById('Label45').value=strReturn;")


child window has

Button1.Attributes.Add("onclick", "window.returnValue =
document.getElementById('TextBox1').value; window.close();")

if im correct - it should pass contents of TextBox1 to the parent and the
parent should show Label45 as the passed back variable - except it does
nothing ?

i feel like im on the right track somewhere!

cheers

Mark
 
im not sure where


both attributes.add statements are on page load,

child has <base target="_self"> between <head> </head>

otherwise another window pops up

am i correct in saying the variable should appear on the parent once ive
clicked the button on the child ?
 
What is the type of Label45?

If it is an asp:Label, it renders as a <span>. To change its text on client
side you should assign to

document.getElementById('Label45').innerText

Eliyahu
 
that did the trick thanks,

BUT

its sending the string back, the label changes, then it quickly changes back
to what it was

(blank) - what causes this ?
 
Likely a postback takes place. The server code knows nothing about the new
value and restores the label to previous blank one.

If you need to persist the value between the postbacks, you should pass it
on to the server in a hidden <input> control. Alternatively you can you a
textbox instead of a label.

Eliyahu
 
works great with a textbox, thanks , how come it doesnt work with labels ?
is it the innerText fucntion causing the issue? i can work with the textbox
tho i think
 
Hi,

Eliyahu said:
What is the type of Label45?

If it is an asp:Label, it renders as a <span>. To change its text on client
side you should assign to

document.getElementById('Label45').innerText

Eliyahu

Why not rather use a standard attribute, with:

document.getElementById( "Label45" ).firstChild.nodeValue

This way, the code will work in both IE and Firefox (about 15% of market
share ;-)

Laurent
 
Laurent Bugnion said:
Hi,



Why not rather use a standard attribute, with:

document.getElementById( "Label45" ).firstChild.nodeValue

This way, the code will work in both IE and Firefox (about 15% of market
share ;-)

that work on postback tho ?, browser isnt important, as its an internal app,
all users use ie6

cheers

mark
 
Hi,
that work on postback tho ?,

The code I gave you is pure client-side. Client-side JavaScript doesn't
have a mechanism to preserve a "control"'s state over a postback.
Setting "innerText" also doesn't, and additionally it doesn't work in
Firefox.
browser isnt important, as its an internal app,
all users use ie6

That's not an excuse for coding against standards in my opinion.
cheers

mark

HTH
Laurent
 
The short answer is that the Label control is not designed for passing
values back to server whereas the Textbox is.

Eliyahu
 
Back
Top