Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script manager control with javascript

Status
Not open for further replies.

Denster

Programmer
Apr 9, 2001
198
GB
I have just been introduced to Ajax and finding it very useful indeed. However when applying to existing pages it is dissabling the javascript on page load. All the javascript is doing is targeting various controls then applying the relevant CSS style to that control. This has been working fine until I add the script manager control to do some partial page updating. Is there a way to get this script manager working with my existing javascript function?
 
Hi

Either you use a blatant library or you did not followed its instructions.

You may google for "javascript multiple onload" and pick one of the solutions ( a pure JavaScript one, which not uses the [tt]onload[/tt] attribute ).

But better tell us what library/libraries are you using, and how. The best would be to post an URL to a publicly accessible copy of your page.

Feherke.
 
Puzzled by this reply!. I'll see if I can clarify...
I am using visual studio 2005 with ajax extensions. The code is as follows ---
Code:
<%@ Page Language="VB" MasterPageFile="~/MainPage.master" AutoEventWireup="false" CodeFile="Payment.aspx.vb" Inherits="Payment" title="Payments" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <asp:ScriptManager id="ScriptManager1" runat="server">
        </asp:ScriptManager>
<div id="content">    
        <p>
         Some content here.
        </p>
</div>     

<script type="text/javascript">

function ShowHide(status) 
{ 

    if(status == 1) 
    { 
        alert("Yes number 1");
    }
    else if (status == 2)
    {
        alert("Yes number 2");
    }
    else
    {
        alert("No");
    }
}
</script>

</asp:Content>

I've replaced the actual functionality with alerts for debug purposes.
in the code behind I'm using this line in the page load event
Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "addScript", "ShowHide(2)", True)

As stated previously this displays a message box with "Yes number 2" until you add the script manager control then it fails to fire.
 
Ok - the actual html is quite lengthy so chopped it down a bit
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]

<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] >
<head id="ctl00_Head1"><title>
	Payments
</title><link href="css/Content.css" rel="stylesheet" type="text/css" /><link rel="stylesheet" href="CSS/potters_generic.css" media="screen" />
</head>
<body>
<form name="aspnetForm" method="post" action="Payment.aspx" id="aspnetForm">
<div id="container">
    <p>
       Some content here
    </p>
</div>     

<script type="text/javascript">

    
function ShowHide(status) 
{ 

    if(status == 1) 
    { 
        alert("Yes number 1");
    }
    else if (status == 2)
    {
        alert("Yes number 2");
    }
    else
    {
        alert("No");
    }
}
</script>

<div>

	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgLG96O3CQLh8vmTCMYeZ+IfwoEIGwoVFZ3dCTPLqvpT" />
</div>

<script type="text/javascript">
<!--
ShowHide(2)Sys.Application.initialize();
// -->
</script>
</form>   
    
</div>
</body>
</html>

As you can see the script manager has added Sys.Application.initialize(); to the end of my calling function. How can I stop it doing this?
 
Hi

That probably you will find out faster asking in a Microsoft related forum.

In meantime try to make sure there is a semicolon ( ; ) after your ShowHide(2) call, so code appended automatically to that line will not mess it up :
Code:
ShowHide(2)[COLOR=red pink];[/color]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top