[02/03][C#]Is this a .NET Framework bug or did I forgot something?
I'm new in VS2003/.NET 1.1. I'm using VB6.0, VS2005, VS2008, and even ASP Classic. I always avoid building applications using VS2002/2003 or .NET 1.0/1.1 because of there are lots of bugs and it gives me hard time in programming.
I'm updating an application built in VS2003. I'll upgrade it to .NET 2.0 next week after applying the changes I've done from the test site to the production server.
This is my problem:
I always encounter this problem in C# using .NET 1.1; the application can't fetch the properties properly of some of the controls I've created when I .
Last time, I've added a Dropdown Listbox and used databinding to insert items inside this control but when I submitted the form and evaluated the result; the selected value is always the 1st one even though I've selected other items.
I've resolved this by adding a hidden text field then assign the selected value to this hidden control through a Javascript and fetch the asssigned value.
Now, I've inserted created a checkbox, assigned checked value from the database during the page load event, but when I'm trying to evaluate the properties of this control during the submit event I can't fetch the values and I received this error message: "error: cannot obtain value".
I don't want to use the same approach I've used in the previous problem.
How to resolve this?
Thanks for any help.
Re: [02/03][C#]Is this a .NET Framework bug or did I forgot something?
No, they doesn't seem to be a bug but, afraid to say, could be your ignorance.
Dropdownlist (DDL) problem:
Are you binding the DDL in page load event? If yes, are you binding it within the condition if this is not a postback? If you are not, then every subsequent postback will cause DDL to rebind, always giving you the first option irrespective of you selecting a value or not.
Checkbox problem:
What specific properties are you trying to access? Could you please post a code for this. Make sure you are setting its value within postback check!
Re: [02/03][C#]Is this a .NET Framework bug or did I forgot something?
Quote:
No, they doesn't seem to be a bug but, afraid to say, could be your ignorance.
Sir, I'm sure it is not ignorance, because I've already finished/deployed many ASP.NET 2.0/3.0/3.5 applications without encountering these kind of problems.
Quote:
Are you binding the DDL in page load event? If yes, are you binding it within the condition if this is not a postback? If you are not, then every subsequent postback will cause DDL to rebind, always giving you the first option irrespective of you selecting a value or not.
The data loads if it is not postback:
vb Code:
if (!IsPostBack && Visible)
{
LoadList();
}
Quote:
What specific properties are you trying to access? Could you please post a code for this. Make sure you are setting its value within postback check!
I think there is no need to check if it is postback because the following sample codes fires during the Click even of a button:
Quote:
Details.STPRateID = STPRateID;
Details.GID = Convert.ToInt32(lblGID.Text);
Details.STPartnerID = Convert.ToInt32(lblSTPartnerID.Text);
Details.BaseRate = Convert.ToDecimal(txtBaseRate.Text);
Details.CounterRate = Convert.ToDecimal(txtCounterRate.Text);
Details.ServiceFeeProvl = Convert.ToDecimal(txtServiceFeeProv.Text);
Details.ServiceFeeMM = Convert.ToDecimal(txtServiceFeeMM.Text);
Details.AgentsCommMM = Convert.ToDecimal(txtAgentsCommMM.Text);
Details.AgentsCommProvl = Convert.ToDecimal(txtAgentsCommProv.Text);
Details.ModifiedByUID = UID;
Details.AutoDeductServiceFee= Convert.ToBoolean(chkIsAutoDeductServiceFee.Checked);
All of the other controls have values but not the checkbox control.
If I evaluate the checkbox while debugging, the whole control is null not only the 'checked' property.
Re: [02/03][C#]Is this a .NET Framework bug or did I forgot something?
is the chkIsAutoDeductServiceFee control added dynamically to the page?
Re: [02/03][C#]Is this a .NET Framework bug or did I forgot something?
Sounds like a ViewState issue. If the control is being added dynamically that could be part of the issue.
Doesn't sound like a bug though. If you could post more code we could take a look.
Re: [02/03][C#]Is this a .NET Framework bug or did I forgot something?
Sorry for late response.
Anyway, I've just added the control by simply dragging from the toolbox to the web-form.
I'll try to patch the .NET Framework 1.1 SP1, I've just found it this patch this morning.
Thanks.