473,785 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript being called from ASP with c# codebehind..... Problemo

Hi,

As a real novice trying to get to grips with c#.NET and html.

I have created a simple showdialogbox which is called from within a
webpage.aspx, I pass values to it from the main page and i also
retrieve values from the ones entered in the dialog box:
<script type="text/javascript">

function callDialog()
{
var name = Name.value

var retrievedData = window.showModa lDialog(
"dialogBox.aspx ", name ,winSettings)

if (retrievedArg != null){

retvalA.value= retrievedData;
}
}
</script>

</HEAD>
<body>
<!--<form id="Form1" method="post" runat="server"> -->
<INPUT id="retvalA" type="text" value="AAA">
<INPUT id="Name" type="text" value="nazim">
<BUTTON onclick="openQu ery()" type="button"> Submit </BUTTON>
</p>
<asp:textbox id="TextBoxPAS " runat="server" ></asp:textbox>

<!-- </form> -->
</body>
</HTML>
BUT I have these problems.....!!

1. As you can see above it only works when I comment out the <form>
tags, Which I think need to be included as I will manipulate the data
in c# as processing needs to be done on some data later.

2. Leads me to how do I actually pass the values to my codebehind [I
cant seem to call the javascript from withim ASP buttons either.
Many Thanks guys, for your help, I dont know where else to turn!!!
Nov 16 '05 #1
3 1888
You can attach javascript to an asp button in the codebehind like this:

myButton.Attrib utes.Add("oncli ck", "openquery( )");

-Jason

nazim wrote:
Hi,

As a real novice trying to get to grips with c#.NET and html.

I have created a simple showdialogbox which is called from within a
webpage.aspx, I pass values to it from the main page and i also
retrieve values from the ones entered in the dialog box:
<script type="text/javascript">

function callDialog()
{
var name = Name.value

var retrievedData = window.showModa lDialog(
"dialogBox.aspx ", name ,winSettings)

if (retrievedArg != null){

retvalA.value= retrievedData;
}
}
</script>

</HEAD>
<body>
<!--<form id="Form1" method="post" runat="server"> -->
<INPUT id="retvalA" type="text" value="AAA">
<INPUT id="Name" type="text" value="nazim">
<BUTTON onclick="openQu ery()" type="button"> Submit </BUTTON>
</p>
<asp:textbox id="TextBoxPAS " runat="server" ></asp:textbox>

<!-- </form> -->
</body>
</HTML>
BUT I have these problems.....!!

1. As you can see above it only works when I comment out the <form>
tags, Which I think need to be included as I will manipulate the data
in c# as processing needs to be done on some data later.

2. Leads me to how do I actually pass the values to my codebehind [I
cant seem to call the javascript from withim ASP buttons either.
Many Thanks guys, for your help, I dont know where else to turn!!!

Nov 16 '05 #2
Jason DeFontes <ja***@defontes .com> wrote in message news:<uK******* *******@TK2MSFT NGP11.phx.gbl>. ..
You can attach javascript to an asp button in the codebehind like this:

myButton.Attrib utes.Add("oncli ck", "openquery( )");

-Jason
I've actually used that and yes it allows me to call the java script
but ONLY when the I remove/comment out the <form> tags [as shown
below]. Now sorry if its a silly question but I need the form tag for
future server side processing?
I cant just omit them from the future webpage, thats why I was stuck.

Any ideas???
nazim wrote:
Hi,

As a real novice trying to get to grips with c#.NET and html.

I have created a simple showdialogbox which is called from within a
webpage.aspx, I pass values to it from the main page and i also
retrieve values from the ones entered in the dialog box:
<script type="text/javascript">

function callDialog()
{
var name = Name.value

var retrievedData = window.showModa lDialog(
"dialogBox.aspx ", name ,winSettings)

if (retrievedArg != null){

retvalA.value= retrievedData;
}
}
</script>

</HEAD>
<body>
<!--<form id="Form1" method="post" runat="server"> -->
<INPUT id="retvalA" type="text" value="AAA">
<INPUT id="Name" type="text" value="nazim">
<BUTTON onclick="openQu ery()" type="button"> Submit </BUTTON>
</p>
<asp:textbox id="TextBoxPAS " runat="server" ></asp:textbox>

<!-- </form> -->
</body>
</HTML>
BUT I have these problems.....!!

1. As you can see above it only works when I comment out the <form>
tags, Which I think need to be included as I will manipulate the data
in c# as processing needs to be done on some data later.

2. Leads me to how do I actually pass the values to my codebehind [I
cant seem to call the javascript from withim ASP buttons either.
Many Thanks guys, for your help, I dont know where else to turn!!!

Nov 16 '05 #3
the framework gets all the data via the post.
you need the form tag.
I've actually used that and yes it allows me to call the java script
but ONLY when the I remove/comment out the <form> tags [as shown
below]. Now sorry if its a silly question but I need the form tag for
future server side processing?
I cant just omit them from the future webpage, thats why I was stuck.

Any ideas???

Nov 16 '05 #4

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

Similar topics

0
1848
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>...
0
8791
by: Scott Wallace | last post by:
I have a page that displays several pictures pulled from a database. I want any one of the pictures to appear in a larger main picture container when the user clicks on it. I want to do this on the client side so that the page doesn't post back. I have the following JavaScript function in my HTML: <script> function change(pic) { centerPic.src=pic
5
2137
by: Allan M. | last post by:
I have a series of select boxes that must be populated client side, because they interact with each other. The design specification calls for these boxes to be updated without having to make a roundtrip to the server. The codebehind seems to be unaware of select box members populated via javascript. So, I'm having to create my own state management solution, (i.e. rewriting the VIEWSTATE mechanism) to persist the state of these select...
2
2842
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added to it to view additional details about the selected result (a second database query is triggered). I want this second query to pop up in a new window, the way it would if I used "window.open" in javascript. I've added a function in the
7
33872
by: =?Utf-8?B?Qw==?= | last post by:
I have a dropdown list as below. I add an onchnage attribute in my codebehind to call some Javascript. I want to get the selected text from my dropdown. What am I doing wrong below? <asp:DropDownList ID="ddlStatus" runat="server" /> In my codebehind
2
2420
Frinavale
by: Frinavale | last post by:
I am attempting to use embedded resources in an Ajax Enabled ASP.NET Web Application. I'm using Visual Studio 2008 and VB.NET server side code. The project is called "EmbeddedResources" with the namespace "EmbeddedResources" My resources are not included when the content is rendered in the browser. I have marked my JavaScript resource as Embedded. I am able to retrieve the path to the resource from the WebResource.axd HTTP Handler during...
4
1597
by: =?Utf-8?B?UmljaGFyZA==?= | last post by:
Hi, I have an ASP .NET page with codebehind in a vb file. The page has a dropdown control, and a JS function which used HTTP XML Request to get the data from the database, and populate the dropdown. Actually, the JS creates the OPTION elements using th retrieved db data, and adds them to the SELECT element using DOM objects. The dropdown works ok, and the items are visible, but when the user clicks "Save" button, and the page posts...
4
4242
by: archana | last post by:
Hi all, i am having one user control. what i want is to add javascript which will gets called on button click of user control. but user control is not working if i add javascript in user control.. but if i add javascript in page in which i am adding user control then that javascript is executed properly. i tested by displaying alert message in javascript. can anyone tell
1
3633
by: ahmh | last post by:
The javascript function is called getsportart2 in the codebehind page_load I have the following Page.RegisterStartupScript("MyScript3","<script type='text/javascript' src='http://www.halaeducation.com/media/modules/sports/getsportart2.js'></script>"); I would like to activate this function as soon as the page load. I do not have a problem with activating this function from the <body onload=""> but I have a problem doing so from...
0
9647
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...
1
10100
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
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
8988
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
7509
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
6744
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
5396
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...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.