Call C# Function From JavaScript/JQuery In Asp.net webforms

前端 未结 5 1327
南旧
南旧 2021-01-19 06:33

So, i have an aspx page which looks like this:

<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"Default.aspx.cs\" Inherits=\"_Default\" %>
         


        
5条回答
  •  不知归路
    2021-01-19 07:17

    You can call C# method by making it webmethod. See this URL: http://www.xdevsoftware.com/blog/post/Call-WebMethod-from-Javascript-in-ASPNET.aspx in Javascript it is call pagemethod.

    But for your example, i would suggest you just pre-populate value pagewho? using asp.net tags when HTML is rendered by asp .net.

    Example (in javascript):

    GoToLink("<%= YourCodeBehindMethodReturingURLToPutHere() %>");
    

    Reference: http://weblogs.asp.net/ahmedmoosa/archive/2010/10/06/embedded-code-and-inline-server-tags.aspx

提交回复
热议问题