views:

233

answers:

2

I have a form , with 5 textboxes, 1 radiobutton group (4 radiobuttons) , and a submit button, i added some "code behind" to handle cases where a user doesnt fill in all the fields,

something like

 if (question.Value == "") // question = a textbox with runat=server property
{
  // handle error
}

the problem is that, the 1st time i fill the form,and click submit, it always sends empty values :S in other words. the above snippet of code will always be true :S can some1 explain to me where did i go wrong ?

note: if the same question been asked before.. please link me..

+2  A: 

Assuming question is a textbox, you want question.Text

chris
@ chris : .. it works after the 1st postback.. so i assume i am using the right properties :)..
Madi D.
A: 

You might want to check and see if you databinding on your button post back is not blanking out your textboxes. You can use;

if(!Page.IsPostBack)
{
    // more code here
}

to make sure that your input items keep their values when you click your button.

Chris
@chris: hmm, somehow u helped me figure out the issue, the problem was that i had a a piece of code that clears the data on pageload() :Dseems like it was causing the uproar... i just added a clear form button instead :D
Madi D.