473,765 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="Add KeyWord.aspx.vb " Inherits="Compo nentSearch.AddK eyWord"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>AddKeyWo rd</title>
<meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
<meta content="Visual Basic .NET 7.1" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
<script language='javas cript'>
function WriteBack() {
if (document.forms[0].TextBox_KeyWor d) {

document.writel n(opener.docume nt.forms[0].TextBox_KeyWor ds.value =
opener.document .forms[0].TextBox_KeyWor ds.value + ' ' +
document.forms[0].TextBox_KeyWor d.value); };
return true;
};
</script>
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:textbox id="TextBox_Key Word" style="Z-INDEX: 101; LEFT: 96px;
POSITION: absolute; TOP: 64px"
runat="server" Width="328px" Height="24px"></asp:textbox><as p:label
id="Label1" style="Z-INDEX: 102; LEFT: 200px; POSITION: absolute; TOP:
32px" runat="server"
Width="120px" Height="24px">K ey Word to Add</asp:label><asp: button
id="Button_Add " onclick="WriteB ack" style="Z-INDEX: 103; LEFT: 192px;
POSITION: absolute; TOP: 96px"
runat="server" Width="56px" Text="Add"></asp:button><asp :button
id="Button_Canc el" style="Z-INDEX: 104; LEFT: 280px; POSITION:
absolute; TOP: 96px"
runat="server" Width="51" Height="24"
Text="Cancel"></asp:button><asp :label id="Label_Error Message"
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.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Button_Cancel.A ttributes.Add(" OnClick",
"javascript:win dow.close();")
Button_Add.Attr ibutes.Add("OnC lick", "javascript:Wri teBack();")

End Sub

Public Sub WriteBack(ByVal sender As System.Object, ByVal e As
System.EventArg s)
If TextBox_KeyWord .Text & "" > "" Then
PostKeyWord(Ope nConnection, Session("SYSTEM _NAME"),
Session("CONTAI NER_NAME"), Session("COMPON ENT_NAME"),
TextBox_KeyWord .Text)
Label_ErrorMess age.Visible = False
Else
Label_ErrorMess age.Text = "Enter a keyword to add"
Label_ErrorMess age.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.Attr ibutes.Add("OnC lick", "javascript:Wri teBack();") 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 1846

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

Similar topics

5
2692
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 function to verify the name fields, age, email and gender. My question is: if I create a function for each field like the code below, what would be the best way to organize the functions and call them? Would I need one main function and place...
5
2365
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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script language="javascript" type="text/javascript"> <!--
2
2044
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 test): <script LANGUAGE="javascript"> <!-- function hiThere() { alert("hi");
39
6551
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. When it completes, it can call a success, or a failure function. The names of these success, or failure functions will differ, and I'd like to know how I can pass the name of a function to my tool, and how my tool can call the function, using that...
0
338
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 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>...
2
5579
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 as hyperlink with hand-cursor when hover. For your information, my TreeView control is on a master page. I have done some tricks but when clicking the node, it does the post-back and my page appears empty with nothing on it except the popup...
3
2401
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 the name of the city and I have a DIV tag which I populate with the results. Now my problem is that, after I get the results back I am not able to select a value from the DIV tag. Here is the complete jsp code. <html> <head>
53
8416
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 language="javascript" type="text/javascript">
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9832
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.