In Asp.net Ajax 1.0, there can only be one scriptmanager, so when there is a template page, you must use scriptmanagerproxy as a bridge. For example:
There are two JS files. jscript1 completes addition and jscript2 completes multiplication.
// Jscript1 File
// Sum
Function sum (m, n)
{
Alert (eval (m) + eval (n ));
}
// Jscript2 File
// Product
Function product (A, B)
{
Alert (eval (a) * eval (B ));
}
Parent template page
<Head runat = "server">
<Title> No title page </title>
<SCRIPT type = "text/JavaScript">
Function getsum ()
{
M = Document. getelementbyid ("text1"). value;
N = Document. getelementbyid ("text2"). value;
Sum (m, n );
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: scriptmanager id = "scriptmanager1" runat = "server">
<Scripts>
<Asp: scriptreference Path = "jscript1.js"/>
</Scripts>
</ASP: scriptmanager>
<Table> <tr> <TD> first value: </TD>
<TD> <input id = "text1" type = "text"/> </TD> </tr>
<Tr> <TD> second value: </TD>
<TD> <input id = "text2" type = "text"/> </TD> </tr>
<Tr> <TD> the sum of the two values is: </TD>
<TD> <input id = "button1" type = "button" value = "and" style = "width: 51px" onclick = "getsum () "/> </TD> </tr>
</Table>
<Br/>
<Asp: contentplaceholder id = "contentplaceholder1" runat = "server">
</ASP: contentplaceholder>
Content Page
<% @ Page Language = "C #" masterpagefile = "~ /Masterpage. Master "autoeventwireup =" true "codefile =" content. aspx. cs "inherits =" content "Title =" untitled page "%>
<Asp: Content ID = "content1" contentplaceholderid = "contentplaceholder1" runat = "server">
<SCRIPT type = "text/JavaScript">
Function getproduct ()
{
A = Document. getelementbyid ("txt1"). value;
B = Document. getelementbyid ("txt2"). value;
Product (A, B );
}
</SCRIPT>
<Asp: scriptmanagerproxy id = "scriptmanagerproxy1" runat = "server">
<Scripts>
<Asp: scriptreference Path = "jscript2.js"/>
</Scripts>
</ASP: scriptmanagerproxy>
<Table>
<Tr>
<TD>
First value: </TD>
<TD>
<Input id = "txt1" type = "text"/> </TD>
</Tr>
<Tr>
<TD>
Second value: </TD>
<TD>
<Input id = "txt2" type = "text"/> </TD>
</Tr>
<Tr>
<TD>
The product of the two values is: </TD>
<TD>
<Input id = "BTN" type = "button" value = "product" style = "width: 51px" onclick = "getproduct ()"/> </TD>
</Tr>
</Table>
</ASP: content>