Click here to Skip to main content
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 OriginalGriff 490
1 Maciej Los 305
2 Richard MacCutchan 270
3 Mathew Soji 220
4 BillWoodruff 210
0 OriginalGriff 8,834
1 Sergey Alexandrovich Kryukov 7,477
2 DamithSL 5,689
3 Maciej Los 5,329
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411028.1 | Last Updated 12 Jun 2013
Copyright © CodeProject, 1999-2014
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