Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am calling Page_Load() method from javascript using __doPostBack(), after calling __doPostBack() if i edit the text in textboxes edited text are not reflecting in c# the texts will be empty. Here is my code
XML
function ReloadPatientDemo(PatID) {     
       document.getElementsByName('HiddenField1')[0].value = PatID;    
       __doPostBack("PatientDemo", "Page_Load");     
   }


Pls help me
Posted
Comments
Madhu Nair 7-Feb-14 7:40am    
Can you post what you have written on Page_Load?
Member 8653959 7-Feb-14 8:07am    
protected void Page_Load(object sender, EventArgs e)
{
string PID1 = HiddenField1.Value.ToString();
if (PID1 != "")
{
DataTable ds = obj.GetPatientDetailsById(PID1);
TxtPdFirstName.Text = ds.Rows[0][1].ToString();
TxtPdMiddleName.Text = ds.Rows[0][2].ToString();
}
}
Member 8653959 7-Feb-14 8:12am    
based on PatiendID i getting other information from database.. later if i edit value in firstname textbox, text will displayed but when u check in c# (ex: string firstname = TxtPdFirstName.Text) firstname value will be empty..

1 solution

try writing the page_load event in the following way-

C#
protected void Page_Load(object sender, EventArgs e) { 

if(!IsPostBack)
{
string PID1 = HiddenField1.Value.ToString(); 
if (PID1 != "") 
{ DataTable ds = obj.GetPatientDetailsById(PID1); TxtPdFirstName.Text = ds.Rows[0][1].ToString(); TxtPdMiddleName.Text = ds.Rows[0][2].ToString(); 
} 
}

}
 
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