How to access asp.net controls in web method in ASP.Net

Last Reply on Apr 08, 2016 04:39 AM By Shashikant

Posted on Apr 08, 2016 01:52 AM

How to access asp.net Controls in web methods ...I m trying to access asp.net controls(label,dropdownlist,textbox..etc) on inside web method ..i m getting error (Object reference not set to an instance of an object)...plz help....if its any posible to access controls in webmethods....? How to Find control on my page...?

You are viewing reply posted by: Shashikant on Apr 08, 2016 04:39 AM.
Posted on Apr 08, 2016 04:39 AM

Hi,

Well, that's not the correct approach. At the web service method level you cannot see anything about the page structure. In this method you can only load your list of items and return it. Where this list is binded to is none of GetListItems' business.

You can manage the display of the Items by implementing a callback function (see http://mattberseth.com/blog/2007/06/aspnet_ajax_invoke_a_static_me.html for example) or by using the UpdatePanel approach.