Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post May 06, 2012 04:44 PM by ASPMVP
Member
18 Points
15 Posts
May 04, 2012 12:24 PM|LINK
Hi,
I´m developing the interface of a WebService.
What I expect to accomplish is just simple as enabled/disabled a button according to some conditions
in the onmouseover and onmouseout events.
I´ve been successful calling to a javascript function on external javascript file or even jQuery using
the OnClientClick event.
I have follow the same steps than on the OnClientClick event:
<script language="JavaScript" src="../funtions/jquery/jquery-1.6.1.min.js" type="text/javascript"></script> <script language="JavaScript" src="../funtions/js/jswebservice1.js" type="text/javascript"></script>
I have add next code on the Page_Load event by avoiding warning messages:
BtnConvertir.Attributes.Add("onmouseover","DesBtn();");
BtnConvertir.Attributes.Add("onmouseout", "ActBtn();");
So as you see I´m trying somenthing very simple as calling a javascript function from an external
javascript file, but there´s somenthing wrong on my proceed since onmouseover event return next error:
"Error on Execution time of Microsoft Jscript:'DesBtn' is not defined"
¿What´s my mistake?
Thank you very much in advance.
Contributor
5079 Points
821 Posts
May 04, 2012 12:40 PM|LINK
Can u confirm the following and try again
- Both these functions (DesBtn & ActBtn) are in jswebservice1.js file.
- File 'jswebservice1.js' is being downloaded (to browser) when u access the page, u could check this using developer tool/firebug.
Star
11997 Points
1797 Posts
Make sure these methods are not in jQuery context means not in
$(document).ready(
});
OR
$(function(){
If it's in jquery context cut methods and paste on top of js file.
May 04, 2012 01:13 PM|LINK
Ramesh T Can u confirm the following and try again - Both these functions (DesBtn & ActBtn) are in jswebservice1.js file. - File 'jswebservice1.js' is being downloaded (to browser) when u access the page, u could check this using developer tool/firebug.
These is the content of jswebservice1.js file:
I still haven´t develop the body functions due to this issue.
/* jQuery + Javascript */
function ActBtn(){}
function DesBtn(){alert(document.forms[0].elements["LstCurrency"].length);}
/* */
As you know if the file path would be wrong,there would appear a warning on Visual Studio 2010
so this sures than file path is right.
I´m running on Internet Explorer 9.0 and also able to test firefox 12.0 with firebug 1.9.1
The error does appear on IExplorer 9.0 but on Firefox 12.0 nothing happens.
About if the file it´s being download I don´t really know.
But I have a question, ¿does my procced correct?
May 04, 2012 01:14 PM|LINK
I still haven´t develop the body of the functions till I solve this issue.
I´ll keep on mind.
May 06, 2012 03:59 PM|LINK
I think I´ve found the error cause.
I´ve add manually a javascript function called test inside the aspx code page instead of using an external file this way:
<script language="javascript" type="text/javascript">
function Test() {
alert("This is only a test");
}
</script>
And it works all great, so obviously for some reason the webservice doesn´t path the right external file.
May 06, 2012 04:44 PM|LINK
Finally Solved,
The point is the way I was calling the external javascript file since I´m using an ScriptManager,
the right way to call an external javascript file is:
1- Add the folder/s within the javascript files to the project
2- Use the Scripts and asp:ScriptReference tag from ScriptManager this way:
<Scripts>
<asp:ScriptReference Path="~/funciones/jquery/jquery-1.6.1.min.js" /> <asp:ScriptReference Path="~/funciones/js/jswebservice1.js" /> </Scripts>
When you type Path you should click on Path Url.. and path the javascript file.
Works great now.
ASPMVP
Member
18 Points
15 Posts
onmouseover onmouseout enabled/disabled button on a webservice
May 04, 2012 12:24 PM|LINK
Hi,
I´m developing the interface of a WebService.
What I expect to accomplish is just simple as enabled/disabled a button according to some conditions
in the onmouseover and onmouseout events.
I´ve been successful calling to a javascript function on external javascript file or even jQuery using
the OnClientClick event.
I have follow the same steps than on the OnClientClick event:
<script language="JavaScript" src="../funtions/jquery/jquery-1.6.1.min.js" type="text/javascript"></script> <script language="JavaScript" src="../funtions/js/jswebservice1.js" type="text/javascript"></script>
I have add next code on the Page_Load event by avoiding warning messages:
BtnConvertir.Attributes.Add("onmouseover","DesBtn();");
BtnConvertir.Attributes.Add("onmouseout", "ActBtn();");
So as you see I´m trying somenthing very simple as calling a javascript function from an external
javascript file, but there´s somenthing wrong on my proceed since onmouseover event return next error:
"Error on Execution time of Microsoft Jscript:'DesBtn' is not defined"
¿What´s my mistake?
Thank you very much in advance.
Ramesh T
Contributor
5079 Points
821 Posts
Re: onmouseover onmouseout enabled/disabled button on a webservice
May 04, 2012 12:40 PM|LINK
Can u confirm the following and try again
- Both these functions (DesBtn & ActBtn) are in jswebservice1.js file.
- File 'jswebservice1.js' is being downloaded (to browser) when u access the page, u could check this using developer tool/firebug.
urenjoy
Star
11997 Points
1797 Posts
Re: onmouseover onmouseout enabled/disabled button on a webservice
May 04, 2012 12:40 PM|LINK
Make sure these methods are not in jQuery context means not in
$(document).ready(
});
OR
$(function(){
});
If it's in jquery context cut methods and paste on top of js file.
ASPMVP
Member
18 Points
15 Posts
Re: onmouseover onmouseout enabled/disabled button on a webservice
May 04, 2012 01:13 PM|LINK
These is the content of jswebservice1.js file:
I still haven´t develop the body functions due to this issue.
/* jQuery + Javascript */
function ActBtn(){}
function DesBtn(){alert(document.forms[0].elements["LstCurrency"].length);}
/* */
As you know if the file path would be wrong,there would appear a warning on Visual Studio 2010
so this sures than file path is right.
I´m running on Internet Explorer 9.0 and also able to test firefox 12.0 with firebug 1.9.1
The error does appear on IExplorer 9.0 but on Firefox 12.0 nothing happens.
About if the file it´s being download I don´t really know.
But I have a question, ¿does my procced correct?
ASPMVP
Member
18 Points
15 Posts
Re: onmouseover onmouseout enabled/disabled button on a webservice
May 04, 2012 01:14 PM|LINK
I still haven´t develop the body of the functions till I solve this issue.
I´ll keep on mind.
ASPMVP
Member
18 Points
15 Posts
Re: onmouseover onmouseout enabled/disabled button on a webservice
May 06, 2012 03:59 PM|LINK
Hi,
I think I´ve found the error cause.
I´ve add manually a javascript function called test inside the aspx code page instead of using an external file this way:
<script language="javascript" type="text/javascript">
function Test() {
alert("This is only a test");
}
</script>
And it works all great, so obviously for some reason the webservice doesn´t path the right external file.
ASPMVP
Member
18 Points
15 Posts
Re: onmouseover onmouseout enabled/disabled button on a webservice
May 06, 2012 04:44 PM|LINK
Finally Solved,
The point is the way I was calling the external javascript file since I´m using an ScriptManager,
the right way to call an external javascript file is:
1- Add the folder/s within the javascript files to the project
2- Use the Scripts and asp:ScriptReference tag from ScriptManager this way:
<Scripts>
<asp:ScriptReference Path="~/funciones/jquery/jquery-1.6.1.min.js" /> <asp:ScriptReference Path="~/funciones/js/jswebservice1.js" /> </Scripts>
When you type Path you should click on Path Url.. and path the javascript file.
Works great now.