0

它没有用,我认为它不会,但我想问你(最后机会)。

我有一个简单的 ascx 文件。它有一个选择元素,当它被选中时(通过网络服务)检索子类别。我想在 ascx.cs 文件中编写我的 web 方法,而不是在其他 asmx 文件中编写。

ASCX.CS 文件

protected void public Page_Load(....){
   //(because i can't give the ascx file path :)
    TheAspxFileWhichContainsMyUserControl = Request.Url.LocalPath
}

[WebMethod]
static public string f_GetSubCats(int _iCatId){
    return "<select><option value=1>One</option></select>";
}

ASCX 文件:

<script type="...">
    $.ajax({
        url: "<%=TheAspxFileWhichContainsMyUserControl%>/f_GetSubCats",
        data:...
        ...........
        success: function(msg){
            // append new select to the container
        }
    })
</script>
4

1 回答 1

0

你可以试试这个

于 2010-10-16T01:07:29.273 回答