Why does webform cannot get data?

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hi,

I built an aspx page with c#. There are many textbox and a
submit button. When I input data in form and click submit,
I saw their values are null in debug window.

I checked namespace is correct.

What is the potential bug in my program?

Thanks
 
Hi,
I think there is some problems in Postback, can u check
the properties once again.

Regards
Mahesh ChandraMouli
 
Hello Tom,
I built an aspx page with c#. There are many textbox and a
submit button. When I input data in form and click submit,
I saw their values are null in debug window.

During which event do you check the values with the debugger ?
If you check the values in Page_Load, the textboxes will not
yet have the new value. They will not have the new value
before the TextBox_Change event. [ At least, if everything's working OK ]
Try checking the values in TextBox_Change or Button_Click.

Best regards,

Eric
 
Hi,

I added breakpoint in button and the insert method to pass
those parameters of textbox to sql.

There are 10 parameters, 3 of them can show values, others
are null.

I checked their properties and id, all are ok.

So, where should I check now?

thanks
 
Hello Tom,
I checked their properties and id, all are ok.
So, where should I check now?

Can you perhaps post the code ( aspx and aspx.cs/aspx.vb ) ?
If it is a lot, please remove the irrelevant parts, so the
code is just enough to reproduce the problem.

Best regards,

Eric
 
Hi Eric,

I have 2 classes. One is for user to register, get and set
user info. Another one is for user to add product info.

Both of them have static insert method. Insert user info
and product info respectively in 2 different classes.

It is the code of the cs file behind the aspx:

protected Web.User objOperator;

private void Page_Load(object sender, System.EventArgs e)
{
objOperator = (Web.User)Session["UserName"];

if(!IsPostBack)
{
this.Bind_New();
}
}

private void button_Click(object sender, System.EventArgs
e)
{
this.Insert_Data(objOperator);
}

I added breakpoint in button method, I saw that all data
can be passed from webform.

private void Insert_Data(Web.User objOperator)
{
try
{
Web.Product.Insert(
objOperator.UserID,
Int32.Parse(this.AreaID.SelectedItem.Value),
this.Addr.Text,
......
);
}
catch(Exception e)
{
Response.Write(e.Message);
}

I added breakpoint here. All webform data were null. It
said error in getting the values. And, it throws
FormatException. Web.Product.Insert method is a way to
insert web form data to DB through Stored Procedure.

But, I use the same way to do register page, but no error.

Can I pass the value in user object to product?

Anyway to narrow down the finding of the bug? I added
breakpoint in product class, but the program did not stop
to let me see their values.

What's wrong with my code?

Thanks for your advice.

Tom
 
Back
Top