Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Parent Child Prob

Author  Topic 

see199
Starting Member

21 Posts

Posted - 2007-07-11 : 00:07:14
i'm using asp.net 2003 building a parent-child page where the child passes a variable back to the parent txtbox when then 'button2' in the child page is clicked.

But now, the problem is that which i click the 'btnsearch' from the parent, it shows a child page as expected, but when i click the 'button2' in child page, it prompts a new window and shows the text i'd type in the textbox (txtID). Nothing is returned to the parent.

Here's the coding written after searching for so many source code from internet.

--------------------------------------------------------------------
parent:

private sub page_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

If (Not IsClientScriptBlockRegistered("Dlg4")) Then

Dim paging As String = "popCP.aspx"
Dim scrp4 As String

' use next line for direct with <base target="_self"> between <Head> and </HEAD>
scrp4 = "<script> var rc = new String ; function doIt4(){ rc= window.showModalDialog('popCP.aspx', null,'status:no;dialogwidth:550px;dialogheight:400px;dialoghide:true;help:no;scroll:no');"
scrp4 += "if(rc!=null){ document.getElementById('txtCP').innerText=rc;} "
scrp4 += "else {window.alert('Nothing returned from child. No changes made to input boxes')}} </script>"

Page.RegisterStartupScript("Dlg4", scrp4)

Me.btnSearch.Attributes.Add("onClick", "doIt4();")

End If
end sub

--------------------------------------------------------------------
child:
at class there, i dim this:
Dim ScriptStr As String = "<script language=""javascript"">"

then, for the button:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ScriptStr &= " window.returnValue=document.getElementById('txtID').value;"
ScriptStr &= "</script>"
Me.lt.Text = Me.ScriptStr
End Sub
--------------------------------------------------------------------

I wonder if i'd make any mistakes somewhere that i din't know. Thx
   

- Advertisement -