|
-
May 30th, 2003, 12:29 PM
#1
Thread Starter
PowerPoster
Controlling Parent TextBox
Page A pops a new window called Page B.
How would I set the text value of Page A's TextBox from Page B's button click event?
I want to do this all on the code behind.
I tried doing this on Page B but to no avail.
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
Dim myControl1 As Control = FindControl("Calendar1")
Dim myControl2 As Control = myControl1.Parent()
Dim parent As Control = Page.Parent
Response.Write(myControl2.ID)
End Sub
-
May 30th, 2003, 01:32 PM
#2
your only option is to set a session variable on B, then also run some javascript that will make page A postback to itself, then populate the textbox via the set session variable. The way are thinking just is not going to be possible.
-
May 30th, 2003, 01:40 PM
#3
Thread Starter
PowerPoster
REALLY? Well try this on for size! It works!!!!!!!!!
Code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim id As String = Request.QueryString("id")
Dim script As String
If id = "1" Then
script = "<script language=""JavaScript"">" & vbCrLf & _
"function SendMeBack(x)" & _
"{window.opener.Form1.txtStartDate.value=x}" & _
vbCrLf & "<" & "/script>"
Else
script = "<script language=""JavaScript"">" & vbCrLf & _
"function SendMeBack(x)" & _
"{window.opener.Form1.txtEndDate.value=x}" & _
vbCrLf & "<" & "/script>"
End If
RegisterStartupScript("SendBack", script)
End Sub
Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
Call TheRegScript(Calendar1.SelectedDate)
End Sub
Private Sub TheRegScript(ByVal theD As String)
RegisterStartupScript("Send", "<script language=""JavaScript"">" & vbCrLf & _
"SendMeBack('" & Calendar1.SelectedDate & "')" & _
vbCrLf & "<" & "/script>")
End Sub
Last edited by jesus4u; May 30th, 2003 at 01:45 PM.
-
May 30th, 2003, 01:50 PM
#4
oh..no I knew you can do all that with the window.opener object in the javascript DOM. but I thought you were trying to do it all server side.
-
May 30th, 2003, 01:52 PM
#5
Thread Starter
PowerPoster
well it is weird how I am using the code behind to fire off client side code
-
May 30th, 2003, 01:54 PM
#6
you are'nt. It is just adding the javascript to the output produced by the server. It doesnt run until it hits the client
-
May 30th, 2003, 01:55 PM
#7
Thread Starter
PowerPoster
-
May 30th, 2003, 01:57 PM
#8
Its all good anyway. It works!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|