473,503 Members | 5,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript file won't work with RegisterClientScript

Hello,

I'm developing an asp.net 2.0 project using VS 2005 on XP sp2 with all
the updates. I have an aspx page with javascript that works fine until I
try to separate the script into a .js file. I've found that only the script
that is called from events set in the aspx.cs file don't work. I eliminated
all script except two functions. One is used with the .cs file and the
other one is not.

First, here's the functino used with the .cs file:
if (!this.IsPostBack)
{

btnFirst.OnClientClick = "return btnFirst_Click()";

}
.... the javascript function is...
function btnFirst_Click()

{

alert("This is btnFirst_Click"):

return false;

}

Now the second javascript function is only

function ShowAlert()
{
alert("This is ShowAlert");
return false;
}

This function is called from another button - button1 - from the
OnClientClick event which I set in the property page..

When I have all the javascript in the aspx page, it all wokrs, but when I
move it to a .js file, the first function doesn't work, but the second one
does.

I don't want to add all my javascript in rhe .cs file because that would
expose all my code - that's why I'm teying to put it in a .js file.

How can I make all the code work using both methods?
Thanks.
--
Matthew.Wells
Ma***********@FirstByte.net
Jun 27 '08 #1
0 872

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

Similar topics

2
2831
by: Brian Bischof | last post by:
I'm trying to add javascript to a page so that it gets executed when the page opens. I also need to do this during runtime b/c the javascript will change each time. In MSDN I saw that you can...
7
22008
by: walter | last post by:
Here is my case : I create a user control which contains One checkbox control to enable/disable the other two textbox control. I'm using server control instead of HTML control, and I don't want to...
3
1266
by: Zdenko Rupcic | last post by:
I want to add a javascript which would execute only if certain requirements are met. Example: If user isn't logged in, a message box would pop up, telling the user he has to log in, but if the...
11
3605
by: Boris Twila | last post by:
i need a tutorial thanks
3
3007
by: First Last | last post by:
Hi, Newbie question: Why use Page.ClientScript.RegisterClientScript* when we can just make a .js file and include a reference to it in the page? (i.e. <script src="myscript.js"...
2
2203
by: baburk | last post by:
Hi all, when I call the javascript method from code behind file of the same page it works fine. ScriptManager.RegisterClientScriptBlock(this, Page.GetType(), "Scroll",...
2
2720
by: Matthew Wells | last post by:
Hello. I'm reposting this because my prioe post's subject line was incorrect. I'm developing an asp.net 2.0 project using VS 2005 on XP sp2 with all the updates. I have an aspx page with...
9
2208
by: Matthew Wells | last post by:
OK, I've narrowed down the problem. This works when in the aspx page <script type="text/javascript" > function btnFirst_Click() { alert("Hello");...
1
4049
by: greatvishal | last post by:
Hi, I have a page where I am trying to render a pdf file using response.contenttype = "application/pdf". when the page has rendered, I need to launch a javascript command to launch the window's...
0
7313
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...
1
6970
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...
0
7441
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...
0
5558
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,...
1
4987
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...
0
4663
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...
0
1489
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 ...
1
720
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
366
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...

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.