Click here to Skip to main content
15,880,503 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,

My question is that , i previously using static property which contains drop down value present in drop down . And i was trying to access this value from user controls parent page from Web method. As web method requires static fields only to get the value .

But i am in chaos regarding this static property is that will it have differnt values as per session or it will contain same value accross same application for all uers ??
Posted
Comments
F-ES Sitecore 5-May-15 7:55am    
You can't access controls etc from a web method. You need to pass everything a webmethod needs in the method parameters. If you want controls to have their values updated then web methods are not the way to do it. To use a webmethod to update controls on the page your javascript needs to get the data it needs from the controls, pass those to the webmethod to "do something" with and that webmethod will return a result, or data, and the javascript needs to update the controls on the page with the data returned by the webmethod. If your webmethod doesn't need to update anything but needs data on the current page then your javscript needs to read that data and pass it to the webmethod via params.

1 solution

While using WebMethods, you need to mark that method as Static. That is done because the method call does not instantiate the Page Class, which happens with normal Page PostBacks. That is the actual benefit of Ajax Calls. More at - Why do ASP.NET AJAX page methods have to be static?[^].

Why are you using Static properties in a Web App? Static properties have application scope. So, you will end up showing details of a different user while trying to access a User's information.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900