473,388 Members | 1,390 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,388 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 1802

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.