473,809 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript functions not working on asp.net page

233 New Member
I have a page that contain input form, a contact us page. I also have a few javascript functions, one in particular sends the visitor back to the home page.

My javascript is not functioning properly, the user is supposed to be directed back to the home page, but instead the page simply seems to reload. I would assume that the form is trying to post back, however, I would like to avoid this if possible. In the past for other asp.net button, I could add:

if (!Page.IsPostBa ck)
{
code here...
}

Is there a similar work around for javascript functions?
Jan 15 '08 #1
6 3538
mcfly1204
233 New Member
I suppose there could be a different issue here. Has anyone at least heard of this type of thing happening previously. To simplify:

-1 .aspx page
-1 contact us form with submit button that initiates method of sending the user input as an email
-1 HTML input of type image that when click is supposed to initiate javascript funtion home(), but does not work properly and instead seems to reload the page.
Jan 15 '08 #2
acoder
16,027 Recognized Expert Moderator MVP
Show your JavaScript code.
Jan 16 '08 #3
mcfly1204
233 New Member
Show your JavaScript code.
Brace yourself,

function navURL(url) {
window.location .href = url;
}
Jan 16 '08 #4
acoder
16,027 Recognized Expert Moderator MVP
OK, so how do you call this code?
Jan 16 '08 #5
mcfly1204
233 New Member
OK, so how do you call this code?
<input type=image src="Images/QuikeyGreenLogo OnGREENfield.gi f" onClick="navURL ('http://www.physicaladv ertising.com'); return false;" />

Previously I did not have return false;. The function now operates properly.

On another note, on this same page, when the submit button is clicked, a c# method is called, I would like to call a different javascript function from that method if possible. Essentially the c# method sends the contents of the contact us page in an email, upon doing so I would like to call a javascript function that grays out the background and makes a div tag present. Can javascript be called from server side controls?
Jan 16 '08 #6
acoder
16,027 Recognized Expert Moderator MVP
Previously I did not have return false;. The function now operates properly.
Yes, that should solve it and has.
On another note, on this same page, when the submit button is clicked, a c# method is called, I would like to call a different javascript function from that method if possible. Essentially the c# method sends the contents of the contact us page in an email, upon doing so I would like to call a javascript function that grays out the background and makes a div tag present. Can javascript be called from server side controls?
Just output the JavaScript from the server-side code to be run when the page loads.
Jan 16 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2539
by: Andy Fish | last post by:
Hi, I want to use an anchor tag to invoke some javascript and I've read that it's bad form to use <a href="javascript:foo()"> I've read endless usenet posts and hint sites on the net, they all suggest different things and I can't get any kind of consistency, and I can't find any solution that works properly for IE, opera and mozilla. many of the recommended solutions go something like this:
9
2114
by: Charlene Russ | last post by:
Learn on-line at your own in a user-centered format with plenty of interaction and personal attention. This is a basic level coursed designed to introduce the novice to intermediate computer user to the JavaScript language, and focuses on creating user interactivity on personal websites. This Object Oriented Language is known for creating a high level of interactivity with minimal coding, and is fairly simple to learn. We will begin...
6
1866
by: KKramsch | last post by:
OK, here's the scenario: I have a CGI script that generates a page with frames (BTW, I'm not crazy about frames, but in this case the decision to use them is out of my hands). In a typical session, the user interacts with two of these frames extensively, and up to the very end of the session, this interaction is handled entirely client-side by a fairly elaborate JavaScript script. (This interaction takes place exclusively via HTML...
136
9468
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
4
10678
by: Steven | last post by:
Hello, I have 3 files -- 1. mainform.aspx 2. mainform.aspx.cs 3. mouse.js mainform.aspx contains a image button ("zoominimgbut") which will exceute C# code, whenever the user clicks on it. mainform.aspx.cs is the code behind for mainform.aspx. Mouse.js contains javascript code which needs to executed
1
1439
by: Liam | last post by:
We recently decided to go from cookieless to cookies, changing web.config to read cookieless=false. Since making that change, I've noticed that javascript functions kept in included libraries are not available. They'd been working for over a year. The libraries are included in the <HEAD> of the HTML page: <script language="javascript" src="../inc/utils.js" type="text/javascript"></script>
1
2195
by: 4levels | last post by:
Dear Folks, I stumbled upon a strange behaviour of the XMLHttpRequest.. Maybe I'm just not well informed enough about its possibilities, so could someone please confirm my question? When I put plain javscript in a file that is read-in through a XMLHttpRequest-object, it's like it is totally ignored. Eg. I have the file ajax_include.html with in it's body the following lines <script type="text/javascript" language="javascript">
5
2225
by: Alex Maghen | last post by:
I frequently find myself wanting to insert some basic client-side JavaScript functions in the page of an ASPX of mine. But I find it so frustrating that I have to actually contruct my JavaScript in C# on the server-side and render it to the client because I can't use the IDs of my controls as they are written in the HTML page itself. Rather, I have to use Control.ClientID to get that ID that I can use in the client-side JS. So my...
8
2610
by: Frank | last post by:
Hi, I am working with VS.NET 2005 Ultimately, I wish to call a JavaScript function from a .js file
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10120
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
9200
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
7662
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
6881
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
5689
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
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
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
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.