简体   繁体   中英

Pass return value from .aspx.cs method to .apsx page

I'm trying to get my project done, but i'm stuck.

All I want to do is pass on my method-return value to the .aspx as regular text.

[WebMethod]
public static String VerySimpleStuff() {
     return "Hello";
}

within the .aspx file i want to call this very simple method now.

<%=namesp._Default.VerySimpleStuff()%>

yet i'm not able to display the text. please help me.

You are doing it right,only problem with this is you are unnecessarily using [WebMethod] attribute.Just remove [WebMethod] attribute and your code will work.

Webmethods in code behind are used for AJAX calls,that is not your requirement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM