惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
Cloudbric
Cloudbric
V
Visual Studio Blog
L
LangChain Blog
A
About on SuperTechFans
B
Blog
T
Tenable Blog
罗磊的独立博客
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
博客园 - 三生石上(FineUI控件)
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
P
Palo Alto Networks Blog
U
Unit 42
WordPress大学
WordPress大学
D
Darknet – Hacking Tools, Hacker News & Cyber Security
N
News and Events Feed by Topic
T
Threat Research - Cisco Blogs
C
Check Point Blog
Security Latest
Security Latest
M
MIT News - Artificial intelligence
Application and Cybersecurity Blog
Application and Cybersecurity Blog
宝玉的分享
宝玉的分享
P
Proofpoint News Feed
NISL@THU
NISL@THU
Forbes - Security
Forbes - Security
S
Securelist
Security Archives - TechRepublic
Security Archives - TechRepublic
Hugging Face - Blog
Hugging Face - Blog
aimingoo的专栏
aimingoo的专栏
Latest news
Latest news
GbyAI
GbyAI
T
Troy Hunt's Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
V2EX - 技术
V2EX - 技术
小众软件
小众软件
Google DeepMind News
Google DeepMind News
K
Kaspersky official blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
N
Netflix TechBlog - Medium
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed

博客园 - andy.wu

聊聊除了生产率之外的东西,比如赚钱效率 一次思维锻炼,使用拼音模糊匹配中文 - andy.wu - 博客园 一些需要解决的问题(Win32) svn howto: svn合并时报错:retrieval of mergeinfo unsupported by 。 Windows Mobile应用开发(1):使用Win32 SDK 开发屏幕手电程序 vs(2005 and 2008)中使用vc++创建智能设备项目失败的正确解决方案 思考:google的opensocial的实现原理 思考:日期类型的数据应该用什么样的具体形式存储到数据库? google got crazy!!! EnableViewState详细分析 - andy.wu - 博客园 NHibernate Tips: 要注意模型与数据库在Null方面的匹配 在iis 6中使用共享目录作为虚拟目录 初学wpf感想 Sql Server 2005全文检索中碰到的问题和分析 asp.net faq: 在html文件中,用js获取session? 给博客园首页管理的建议 china-pub,当当,卓越购书经验谈 使用Emacs代替Windows下的Command shell 经验:使用.net 2.0中的TransactionScope碰到的问题
AjaxPro基础知识 and FAQ
andy.wu · 2008-10-09 · via 博客园 - andy.wu

AjaxPro基础知识 and FAQ


演练(walkthrough)

是从实际的项目中抽取出来的,目的是备忘,以后看时有条理。
我只用到了ajaxpro.2.dll

1. 在web.config中的system.web/httpHandlers小节:
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>

2. 在Page_Load事件中注册页面类型:


protected void Page_Load(object sender, EventArgs e)
{
    AjaxPro.Utility.RegisterTypeForAjax(typeof(WebAdmin_RefreshCompleteScore));
}

注意:必须使用typeof,如果使用了this.GetType()则没有效果。因为没有相关文档,我也没费那心思,所以不是很清楚原因。(这个问题耗费了我两天的时间才顿悟,粗心大意加自由散漫害死人啊, 以后一定照标准做)

3. 将方法标记为[AjaxPro.AjaxMethod]:


[AjaxPro.AjaxMethod]
public string Hello()
{
    return "Hello, now is " + DateTime.Now;
}

4. 在页面中写js脚本


<script type="text/javascript" language="javascript">
function Hello()
{
    AjaxPro.timeoutPeriod = 150000 // 设置超时的时间, 这里只是演示一下,大多数情况不用写
    var info = "请稍候,正在处理数据..."
    $('#cc_lblMessage').html(info);
    WebAdmin_RefreshCompleteScore.Hello(CallBack);
}
function CallBack(rc)
{
    alert(rc.value);
}
</script>

Q: 如何同步调用

var result = ClassName.func();
就是同步调用

Q: 服务器端的方法能返回对象吗

可以的,这个真是方便,估计ajaxpro直接处理成json了,哈哈,在c# 3中使用匿名类更爽。


[AjaxPro.AjaxMethod]
public object Delete(int id)
{
    ......
    if (userCnt > 0)
    {
        return new { IsSuccessful = false, Message = "该用户组存在用户,不能删除。" };
    }
    else
    {
        ......
        return new { IsSuccessful = true, Message = "该用户组已删除。" };
    }
}

ps: c# 3的匿名类是只读的,哎真不爽啊