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

i want to access hidden field value in webmethod which is global in the application. if i pass it via parameter it will aloow me .. but in code behind i always get old value only .

please suggest
Posted
Comments
JoCodes 8-Nov-13 3:54am    
R u passing the clientid of the hiddenfield as the parameter?
Rahul_Pandit 8-Nov-13 3:59am    
Please tell me clearly what is ur hidden field exactly doing?
Torakami 8-Nov-13 6:09am    
hidden field is we are using through out the page .. its contain important id which is help for bindng purpose ..

1 solution

Web Method can be used for Two purpose


You won't get the updated value of Hidden field in web method because web method run in the server and server doesn't aware about value changes done in client side before Postback.

if your purpose of web method is AJAx Call ,
you can send the updated value of hiddenfiled as a parameter value in ajax call.






-shazid
 
Share this answer
 
Comments
Torakami 8-Nov-13 7:01am    
yes shazid .. i am agree with you but if i send as a parameter during the ajax call the updated hiddenfield value i wont get it for next scope ..
Md.Shazid hasan 8-Nov-13 7:06am    
you can try to update the HIddenfieldValue in the web Method like :
[webMethod()]
public static string test (string hfValue)
{
hiddenField.Value = hfValue;

....other ...business ..owrk
}

This way you can update server state of that HidenField
Torakami 8-Nov-13 7:30am    
it wont allow me to access hideenfield inside webmethod .. no server control can be accessable inside webmethod ... and thats what the problem is
Md.Shazid hasan 8-Nov-13 23:32pm    
Then you have to send the updated value Every time you call

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