Link to home
Start Free TrialLog in
Avatar of mannevenu26
mannevenu26

asked on

ASP.NET with C#

I am trying insert values into data base.using ASP.Net(C#).

Emp Name: Textbox (validation ontrol Required field)

Emp Id :  TextBox

Country : Text box

Submit Button

* After successfull insertion i want to display it in label like "Successfully Inserted".
Up to here No issues. I am able to do.

Now again i removed text box value.click it on submit.Validation is coming fine.But "Successfully Inserted message  " still there.

I want to clear of this message when i click second time sumbit button if any validation happens.
Avatar of Monica P
Monica P
Flag of India image

Hi

In button click event check for the page is valid or not and then make the insert statement to get executed

   
  
        if (Page.IsValid)
        {
               -- Write the database insertion code here            
                   Literal1.Text = "Inserted successfully";
        }
       

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of XGIS
XGIS
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Write below code in button click event.

button1_Click()
{
    Label1.Text = "";
   //OR
       Label1.Text = string.Empty;

     //Remaining code


}
Write below code in button click event.

button1_Click()
{
 
   {
       //code for Insert
   }
 
       Label1.Text = string.Empty; 

     //Remaining code


}

Open in new window