Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Javascript file won't work with RegisterClientScript

0 views
Skip to first unread message

Matthew Wells

unread,
May 8, 2008, 1:50:55 PM5/8/08
to
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
Matthe...@FirstByte.net


0 new messages