473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Unable to call javascript function AND post with same buttom

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 ...

Oct 19 '05 #1
0 1796

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one...
5
by: Terje Sæternes | last post by:
It seems that this script wont run, any idea what I have don wrong+ Code----- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title>...
2
by: ryan.mclean | last post by:
Hello everyone. Hope ya'll had a nice New Year. Anyway, my question is why won't this work? I must be doing something dumb . . . here is the code: in the body tag, I have this code (just to...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
0
by: Prescott | last post by:
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...
2
by: Antonio | last post by:
Hi, I would like to have my TreeNode to call window.close(); without posting back, how can I do that? At the same time, I prefer to have a SelectAction property that allows my TreeNode to appear...
3
by: ashishc | last post by:
Hi All, I have written a AutoSuggest in jsp and am using javascript to call the strut page which calls the database and returns me the xml back. On the html page i have a text box where i enter...
53
by: souporpower | last post by:
Hello All I am trying to activate a link using Jquery. Here is my code; <html> <head> <script type="text/javascript" src="../../resources/js/ jquery-1.2.6.js"</script> <script...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.