How JavaScript invokes procedures and ASP.net calls in C # background code

Source: Internet
Author: User
+++++++++++++++++ First case:

1. Background method:

Protected string Csharpvoid (String STRCC)
{

return STRCC;

}

2.javascript Call
<script language= "JavaScript" >

var s = "<%=csharpvoid (" www.esoutong.com ")%>";
document.write (s);

</script>


+++++++++++++++++ the second case:

1. Post Code:
protected void csharpvoid ()
{
String STRCC = "www.esoutong.com";
Response.Write (STRCC);

}

2. Calling method: Csharpvoid ()

<script language= "JavaScript" >
document.write ("<%csharpvoid ();%>");
</script>


  • You can put a button on the page, set it to invisible style= "Display:none", and then use the script to make this button click
    document.all ("Button1"). Click ();
    Write the event code in the C # Background of this button, which is the simplest script to invoke the C # method.


    On the Internet to see this problem: The author uses the platform is. NET, with C # in the native development, in the ASPX file to call JS file:

    <script language= "javascript" src= "Mymenu.js" ></script>

    Results in the page and alert hint of the Chinese are garbled, to find solutions. The results are followed by a long list of solutions, in fact very simple, in the head of the ASPX file to add a line of code can:

    <%@ Page contenttype= "text/html" responseencoding= "gb2312"%>



  • 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.