Click here to Skip to main content
11,494,407 members (64,435 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
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 11-Jun-13 20:33pm
Comments
Nandakishorerao at 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.
Dhanesh P M at 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?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
v3
Comments
Aatif Ali from Bangalore at 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 EBRAHIMI HOMAY at 12-Jun-13 1:50am
   
Ok Ali please give it me for thinking about, But I think try to change your solution ;)
AYDIN EBRAHIMI HOMAY at 12-Jun-13 1:51am
   
Do you want to the find a control from asp.net web page?
Aatif Ali from Bangalore at 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 EBRAHIMI HOMAY at 12-Jun-13 4:37am
   
ya, you right if you are find a solution please tell me it is amazing for me ;)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

var x=Page.FindControl("YourControlId");


for example:

var x=Page.FindControl("txtSample");
 
x.text="Sample text";

[edit]Code block added[/edit]
  Permalink  
v2
Comments
Aatif Ali from Bangalore at 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)

  Print Answers RSS
0 Dnyaneshwar@Pune 740
1 Sergey Alexandrovich Kryukov 443
2 CHill60 350
3 Nakul Chaudhari 236
4 OriginalGriff 221
0 Sergey Alexandrovich Kryukov 10,277
1 OriginalGriff 8,805
2 Sascha Lefèvre 3,704
3 Maciej Los 3,392
4 Richard Deeming 2,500


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 12 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100