Scriptmanagerproxy in ASP Ajax 1.0

Source: Internet
Author: User

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.