1

I am using asp.net3.5 C# with Jquery

I have created a webUserControl timer.ascx, I have a page showTime.aspx I have added timer.ascx into ShowTime.aspx on drodown change I want to display the current time.

but I am getting this error

This type of page is not served. Description: The type of page you have requested is not served because it has been explicitly forbidden. Please review the URL below and make sure that it is spelled correctly.

timer.ascx

[WebMethod]
public static string returnTime()
{
    return DateTime.Now.ToString();
}

showTime.aspx

$(function () {
        $(".currDropDown").change(function () {
            $.ajax({
                type: "POST",
                url: "time.ascx/returnTime",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                    $(".timeLbl").text(msg.d);
                }
            });
            return false;
        });
    });

is it that I cant call ajax request inside webusercontrol or there is something wrong in code. please help.

Regards

1 Answer 1

4

You can't host ASP.NET AJAX page methods within ASCX controls, only in ASPX code behind (or, you could use an ASMX ScriptService to centralize the functionality).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.