开发者

Can I access asp.net server control in Ajax.AjaxMethod?

How can i access asp.net server control in Ajax.AjaxMethod. My code is below.

 protected void Page_Load(object sender, EventArgs e)
{

    Ajax.Utility.RegisterTypeForAjax(typeof(Default2));
}


[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public void CreateModelPopupForRenameApplication()
{
    Timer1.Enabled = true;
}

I am getting error开发者_C百科.......on Timer1 (object ref not set)


Ajax methods are not meant to interact with the server controls on your page in this way, because you are not actually running through the page lifecycle like when you normally load the page. That's why it cannot find the Timer1 object.

You should think of these methods as stand-alone functions that calculate a value or do something independently of any page controls.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜