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

is there any way to access asp.net controls from Page methods(web methods).i am really stuck ma project in last couple of weeks..pleas help me..

Thanks n Advnce
Aatif Ali-Bangalore
Posted
Comments
Nandakishore G N 12-Jun-13 1:50am    
no you cant access controls in webmethod. So, Create a class and load the values to its members.and create class instance and access the members.
[no name] 28-Oct-14 3:06am    
Hi, I am also facing the same issue. if this problem fixed, can you please tell me how you solved it?

 
Share this answer
 
v3
Comments
Aatif Ali from Bangalore 12-Jun-13 1:40am    
hi friend,i think you are mistaken... i want to call page controls from web methods..not from normal c# methods..i will try different alternatives...but i unlucky...web methods s a static method ...thats the problem..
Aydin Homay 12-Jun-13 1:50am    
Ok Ali please give it me for thinking about, But I think try to change your solution ;)
Aydin Homay 12-Jun-13 1:51am    
Do you want to the find a control from asp.net web page?
Aatif Ali from Bangalore 12-Jun-13 2:21am    
ya,sure..i want to find or accessing controls from a web method..in normal case it is easy to find out..but in web methods, i think it somewhat complex...
Aydin Homay 12-Jun-13 4:37am    
ya, you right if you are find a solution please tell me it is amazing for me ;)
C#
var x=Page.FindControl("YourControlId");



for example:

C#
var x=Page.FindControl("txtSample");

x.text="Sample text";


[edit]Code block added[/edit]
 
Share this answer
 
v2
Comments
Aatif Ali from Bangalore 12-Jun-13 6:46am    
check above solution and corresponding Comments...

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