Why does webform cannot get data?

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
 
M

Mahesh ChandraMouli[MVP]

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

Regards
Mahesh ChandraMouli
 
E

Eric Veltman

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
 
T

Tom

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
 
E

Eric Veltman

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
 
T

Tom

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top