I want to execute a javascript function that will set a value in the
parent window from the child widow where its called and then post the
form to the server. I seem to be able to execute one or the other but
not both. The child page (html) code is:
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="AddKeyWord.aspx.vb" Inherits="ComponentSearch.AddKeyWord"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>AddKeyWord</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script language='javascript'>
function WriteBack() {
if (document.forms[0].TextBox_KeyWord) {
document.writeln(opener.document.forms[0].TextBox_KeyWords.value =
opener.document.forms[0].TextBox_KeyWords.value + ' ' +
document.forms[0].TextBox_KeyWord.value); };
return true;
};
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:textbox id="TextBox_KeyWord" style="Z-INDEX: 101; LEFT: 96px;
POSITION: absolute; TOP: 64px"
runat="server" Width="328px" Height="24px"></asp:textbox><asp:label
id="Label1" style="Z-INDEX: 102; LEFT: 200px; POSITION: absolute; TOP:
32px" runat="server"
Width="120px" Height="24px">Key Word to Add</asp:label><asp:button
id="Button_Add" onclick="WriteBack" style="Z-INDEX: 103; LEFT: 192px;
POSITION: absolute; TOP: 96px"
runat="server" Width="56px" Text="Add"></asp:button><asp:button
id="Button_Cancel" style="Z-INDEX: 104; LEFT: 280px; POSITION:
absolute; TOP: 96px"
runat="server" Width="51" Height="24"
Text="Cancel"></asp:button><asp:label id="Label_ErrorMessage"
style="Z-INDEX: 105; LEFT: 104px; POSITION: absolute; TOP: 136px"
runat="server" Width="328px" Height="24px" Visible="False"
ForeColor="Red"></asp:label></form>
</body>
</HTML>
The VB.NET Codebehind function is named the same as the javascript
function (a technique that was detailed in this group) and the entire
codebehind code is:
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
Button_Cancel.Attributes.Add("OnClick",
"javascript:window.close();")
Button_Add.Attributes.Add("OnClick", "javascript:WriteBack();")
End Sub
Public Sub WriteBack(ByVal sender As System.Object, ByVal e As
System.EventArgs)
If TextBox_KeyWord.Text & "" > "" Then
PostKeyWord(OpenConnection, Session("SYSTEM_NAME"),
Session("CONTAINER_NAME"), Session("COMPONENT_NAME"),
TextBox_KeyWord.Text)
Label_ErrorMessage.Visible = False
Else
Label_ErrorMessage.Text = "Enter a keyword to add"
Label_ErrorMessage.Visible = True
End If
End Sub
Why won't the client run both the javascript and then execute the
writeback sub in the code behind?? If I comment out the line
Button_Add.Attributes.Add("OnClick", "javascript:WriteBack();") in the
codebehind the WriteBack sub in the codebehind is executed. If I leave
it in the javascript is executed and the value is written back to the
parent properly, but not the codebehind is executed. Any help would be
greatly appreciated. Thanks,
Prescott ...