调用使用jQuery的ASCX页的方法 [英] calling an ascx page method using jquery

查看:416
本文介绍了调用使用jQuery的ASCX页的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以使用下面的语法调用使用jQuery一个页面的方法

I know that I can call a page method with jquery using the following syntax

$.ajax({
  type: "POST",
  url: "Default.aspx/GetDate",
  data: "{}",
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg) {
    // Replace the div's content with the page method's return.
    $("#Result").text(msg.d);
  }
});

这适用于 ASPX 页,但有可能是 ASCX 页? (Web控件)

This works for aspx pages but is it possible with ascx pages? (web controls)

我一直想它大约一个半小时,因为我无法得到它的工作我想知道如果它甚至有可能。

I've been trying it for about half an hour and since I can't get it to work I'm wondering if it's even possible.

请注意:只是要清楚,当我尝试打电话给ASCX页面我上午更新网址jQuery中:)

Note: Just to be clear, when I try to call the ascx page I am updating the url in jquery :)

推荐答案

没有,因为ASCX控件不重新present,可以从客户机访问的实际网址。他们是纯粹的服务器端意味着其他页面中嵌入。

No, because ascx controls don't represent a real URL that can be accessed from a client machine. They're purely server-side meant to embed in other pages.

你也许想要做的就是有一个ASPX页面,提供HTML在你的ASCX文件的相同片段您目前拥有。一个aspx页面不一定需要提供一个完整的HTML文档(小于HTML><身体>等),它可以只呈现你感兴趣的用户控件

What you might want to do is just have an aspx page that provides the same snippet of html you currently have in your ascx file. An aspx page doesn't necessarily need to provide a full html document (<html><body> etc.), it can just render the user control you're interested in.

我们使用这种技术所有的时间与英格丽插件,它要求对表的内容回调网址。

We use this technique all the time with the ingrid plugin, which requires a callback url for the table contents.

这篇关于调用使用jQuery的ASCX页的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆