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
try using firefox to debug the script, you must have a syntax error.
-- bruce (sqlwork.com)
From the aspx.cs OnLoad event...
btnFirst.OnClientClick = "return btnFirst_Click()"
the javascript function for that event is
function btnFirst_Click()
{
alert("This is btnFirst_Click");
return false;
}
This doesn't work, but this does
function Button1_Click()
{
alert("This is ShowAlert");
return false;
}
In the property page for Button1, I manually put "ShowAlert()" in the
OnclientClick event - it works that way.
I even switched the functions and still the one that is bound in the aspx.cs
code won't work.
Does someone else have a clue?
"bruce barker" <nos...@nospam.com> wrote in message
news:ucOkdDZs...@TK2MSFTNGP04.phx.gbl...