Click here to Skip to main content
15,903,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have created an wcf service application and in my visual webpart i have an search button an some textboxes my button looks like this, '

int id;
           bool ok = int.TryParse(TextBoxSearch.Text, out id);

           if (ok)


           var service = new ServiceReference.Service1Client("http://localhost:54187/Service1.svc");


               var product = service.GetProduct(id);

           catch (Exception)

               throw new FaultException();


       private void UpdateTextBoxes(Product product)

           TextBoxName.Text = product.ProductName;
           TextBoxProductNumber.Text = product.ProductNumber;
           TextBoxListPrice.Text = product.ListPrice.ToString(CultureInfo.InvariantCulture);
           TextBoxColor.Text = product.Color;
           TextBoxSearch.Text = product.ProductID.ToString(CultureInfo.InvariantCulture);

and when pressing the button i get
An unexpected error has occurred
and randoms Correction id everytime , i dont know what to do:(

1 solution


I'm more into VB than C or java but looking at your curly brackets,Im not sure but i would hazard a guess that where you have

if (ok)

You should remove the }

And maybe thats right, but i could be wrong.
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