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


On page load i am firing methiod which sets value to controls , labels , dropdown and other things ..

i am making other ajax call from other link , and that webmethod again calling my first method , but this time ..all controls gets null and not be able to set value and throwing an error object reference not set to instance of an object
Posted
Comments
Kumarbs 1-Aug-14 2:59am    
In service method, no controls will be identified.
Torakami 1-Aug-14 3:06am    
from service method i am calling my other method which is normal public method , there controls gets null
Torakami 1-Aug-14 3:08am    
My normal public method is the one which gets call on page load even ... but the same method when i try to call from service method , controls becomes null and further value not be able to assign , and hence getting an error ..please suggest
Kumarbs 1-Aug-14 3:10am    
No matter which method you called, you won't get the controls in the web methods. They are pure c# methods, you won't identify any asp.net control.

1 solution

Put your page_load code inside "if(!IsPostBack)"

C#
protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
        //Your Code to set value to control
     }
 }
 
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