Click here to Skip to main content
15,912,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends.
I have an aspx page with some textboxes and combo boxes and a button.A javascript function is added for the button for its click event for clientside validation. The problem is...After entering some data when i am pressing the button, the datas i entered is getting lost..as if the page is being refreshed.I have set the "AutoPostBack" Property for all the text boxes and dropdownlists to false; I am very new to asp.net.
Can somebody help me plse.Any help will be highly appreciated.
Posted

look man i dont understand correctly but it is normaly when you press a button the page must PostBack or refreshed i think even if you put the combo and check AoutoPostBack = false .

There is another way to keep the data, onButtonClick you can take the data (ex: textBox) and store is in viewstate or session then you can check in page load if the session is not empty give the cobmo the value in session

C#
protected void Button2_Click(object sender, EventArgs e)
{
 if(!string.IsNullOrEmpty(txtBox.Text))
  {
    session["Value"] = txtBox.Text;
    ...
    ...
  }
}

and in 
protected void Page_Load(object sender, EventArgs e)
    {
       if (session["Value"] != null)
       {
         txtBox.text = (string)session["Value"]
       }
      Session.Remove("Value");
    }
Best Regards.
 
Share this answer
 
Comments
Pallab_GT 22-Oct-11 23:05pm    
Thank you very much for your reply youssef. I have solved the problem and first part of your answer is correct.
I sincerely really appreciate your help.
Try this one

Place EnabledViewState="true" in page directive or to all the controls
 
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