I have played enough with this. I need help.

G

Guest

Hi,
I have a parent page that loads a popup and when the OK button is press it
pass the value back to the parent form textbox. It passes the value but it
doesn't close the popup but also open another copy of the popup. Guys I
checked everywhere. I get the same thing.

This is the code on the parent form webform1.aspx

HTML

<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 240px; POSITION:
absolute; TOP: 144px" runat="server"
Text="Button"></asp:Button>
<asp:TextBox id="txtValue" style="Z-INDEX: 102; LEFT: 240px; POSITION:
absolute; TOP: 104px"
runat="server"></asp:TextBox>
</form>
</body>



VB CODE



Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

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




End Sub

This is the code for the child (popup) child.aspx

HTML

<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:TextBox id="txtValue" style="Z-INDEX: 101; LEFT: 224px; POSITION:
absolute; TOP: 104px"
runat="server"></asp:TextBox>
<asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 224px; POSITION:
absolute; TOP: 144px" runat="server"
Text="Button"></asp:Button>
<asp:Button id="Button2" style="Z-INDEX: 103; LEFT: 296px; POSITION:
absolute; TOP: 144px" runat="server"
Text="Button"></asp:Button>
</form>
</body>


VB CODE

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

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

Button2.Attributes.Add("onclick", "window.close();")
End Sub



I would really appreciate any help on this. I gave it my best shot.

Thanks
 
K

Ken Dopierala Jr.

Hi Chris,

In your popup add a <head> tag like this:

<Head>
<BASE target="_self">
</Head>

The problem is that with out the target tag your popup will act funny when
it posts back to itself because it is Modal. Good luck! Ken.
 
K

Ken Dopierala Jr.

Hi Chris,

I forgot, also do this, it doesn't look like you are even expecting to post
back, but you are:

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

Button2.Attributes.Add("onclick", "window.close(); return false;")

Without the 'return false;', those buttons are causing a post back. Good
luck! Ken.
 
G

Guest

Once again I live to tell the tail! Thanks! Worked perfect.

Where can I find info on using these javascript with asp.net
 

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,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top