views:

40

answers:

1

It didn't work and i think it won't but i wanted to ask you(last chance).

I have a simple ascx file. It has one select element which retrieves sub categories when it is selected (over web service). I want to write my web method in ascx.cs file instead of to write in other asmx file.

ASCX.CS file

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 file:

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

you can try with this

y34h