S
sqlboy2000
Hello all,
I have something very simple going on here and I'm scratching my head
as to what the problem is. There are 4 items in my project, 2 webforms,
a user control, and a module:
WebForm1.aspx
ChangeValue.aspx
WebUserControl1.ascx
Module1.vb
Here's the flow:
WebForm1 is the start page and has a placeholder that gets populated
with WebUserControl1. Module1.vb has a public variable called strTest.
The page load of WebForm1 set this string to "Some Value". (Provided
it's not a postback)
On WebUserControl1, there is a textbox and a label. The page load of
the usercontrol sets the values of both the textbox and the label to
the value of strTest. (So it gets set to "Some Value" on the first
load. There is a plain old html button on WebUserControl1 that executes
some client script to open a popup window. The popup window opens
ChangeValue.aspx.
ChangeValue.aspx has some code in the page load that changes the value
of strTest from "Some Value" to "New Value". It also has a button that
executes some client script to refresh the parent window and close the
popup.
So the value of both the textbox and the label in the usercontrol
should now read "New Value". However, ONLY the label is getting
updated. This is utterly confusing, my page is definitely getting
refreshed or the label would still say "Some Value" instead of "New
Value". The code for each of the 4 items follows, I can't figure this
one out for the life of me. Any help would be appreciated.
Here's Module1:
Module Module1
Public strTest As String
End Module
Here's WebForm1.aspx (HTML):
<body>
<form id="Form1" method="post" runat="server">
<asplaceHolder id="PlaceHolder1" runat="server"></asplaceHolder>
</form>
</body>
Here's WebForm1.aspx (Code Behind):
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
If Not Page.IsPostBack Then
strTest = "Some Value"
End If
Dim ctrTextBox As WebUserControl1
PlaceHolder1.Controls.Clear()
ctrTextBox = LoadControl("WebUserControl1.ascx")
ctrTextBox.ID = "WebUC1"
PlaceHolder1.Controls.Add(ctrTextBox)
End Sub
Here's WebUserControl1.ascx (HTML):
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<br>
<asp:Label id="Label1" runat="server">Label</asp:Label><br>
<INPUT type="button" value="Open Popup"
onclick="window.open('ChangeValue.aspx')">
Here's WebUserControl1.ascx (VB):
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
TextBox1.Text = strTest
Label1.Text = strTest
End Sub
Here's ChangeValue.aspx (HTML):
<body>
<form id="Form1" method="post" runat="server">
<INPUT type="button" value="Change variable and reload parent"
onclick = "reloadAndClose()">
</form>
</body>
Here's ChangeValue.aspx (VB):
<HEAD>
<script>
function reloadAndClose() {
window.opener.document.Form1.submit();
window.close();
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<INPUT type="button" value="Change variable and reload parent"
onclick = "reloadAndClose()">
</form>
</body>
I have something very simple going on here and I'm scratching my head
as to what the problem is. There are 4 items in my project, 2 webforms,
a user control, and a module:
WebForm1.aspx
ChangeValue.aspx
WebUserControl1.ascx
Module1.vb
Here's the flow:
WebForm1 is the start page and has a placeholder that gets populated
with WebUserControl1. Module1.vb has a public variable called strTest.
The page load of WebForm1 set this string to "Some Value". (Provided
it's not a postback)
On WebUserControl1, there is a textbox and a label. The page load of
the usercontrol sets the values of both the textbox and the label to
the value of strTest. (So it gets set to "Some Value" on the first
load. There is a plain old html button on WebUserControl1 that executes
some client script to open a popup window. The popup window opens
ChangeValue.aspx.
ChangeValue.aspx has some code in the page load that changes the value
of strTest from "Some Value" to "New Value". It also has a button that
executes some client script to refresh the parent window and close the
popup.
So the value of both the textbox and the label in the usercontrol
should now read "New Value". However, ONLY the label is getting
updated. This is utterly confusing, my page is definitely getting
refreshed or the label would still say "Some Value" instead of "New
Value". The code for each of the 4 items follows, I can't figure this
one out for the life of me. Any help would be appreciated.
Here's Module1:
Module Module1
Public strTest As String
End Module
Here's WebForm1.aspx (HTML):
<body>
<form id="Form1" method="post" runat="server">
<asplaceHolder id="PlaceHolder1" runat="server"></asplaceHolder>
</form>
</body>
Here's WebForm1.aspx (Code Behind):
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
If Not Page.IsPostBack Then
strTest = "Some Value"
End If
Dim ctrTextBox As WebUserControl1
PlaceHolder1.Controls.Clear()
ctrTextBox = LoadControl("WebUserControl1.ascx")
ctrTextBox.ID = "WebUC1"
PlaceHolder1.Controls.Add(ctrTextBox)
End Sub
Here's WebUserControl1.ascx (HTML):
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<br>
<asp:Label id="Label1" runat="server">Label</asp:Label><br>
<INPUT type="button" value="Open Popup"
onclick="window.open('ChangeValue.aspx')">
Here's WebUserControl1.ascx (VB):
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
TextBox1.Text = strTest
Label1.Text = strTest
End Sub
Here's ChangeValue.aspx (HTML):
<body>
<form id="Form1" method="post" runat="server">
<INPUT type="button" value="Change variable and reload parent"
onclick = "reloadAndClose()">
</form>
</body>
Here's ChangeValue.aspx (VB):
<HEAD>
<script>
function reloadAndClose() {
window.opener.document.Form1.submit();
window.close();
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<INPUT type="button" value="Change variable and reload parent"
onclick = "reloadAndClose()">
</form>
</body>