I have a code behind file that on page load sets up a form. this form has a dropdownlist to select which form you'd like to view.
When selecting a different view a onSelectedIndexChanged method is called, i can see this is being called. When the index changes it sets a global boolean depending on what is selected, e.g if
"formulation" is selected global bool form = true;
therefore later when i have filled in the form and click submit the onClick event is fired, but it still thinks the bool is false, it is not recognising the change in variable value,
is there anyone out there that can clear this up for me.. basic code below
public partial class ProductSearch : PageBase
{
StringBuilder builder;
List<string> errorMessages;
Document doc;
bool formulationSearch = false;
bool batchSearch = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
errorMessages = new List<string>();
SetupBatchForm();
SetupLanguageSelect();
language_select.SelectedValue = "2";
}
}
private void SetupBatchForm()
{
search_by.SelectedValue = "batch";
batchSearch = true;
batch_input.Visible = true;
batch_help.Visible = true;
formulation_input.Visible = false;
formulation_help.Visible = false;
}
code Submit button onClick
protected void SubmitSearch(object sender, EventArgs e)
{
Response.Write("Submited");
Response.Write(batchSearch);
if (batchSearch)
{
SubmitBatchSearch();
}
else
{
SubmitFormulationSearch();
}
}