Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a new web app that is based on an old desktop app. I need help on how to make changes to old GetCaseButton_Click desktop app code and make it work for new web app.

The old code is using Combobox and MessageBox for error message. My web app aspx code is using DropDownList and ClientScript for error message.

How do I change Combobox code to DropDownList?

The code is very long 200 lines. So I have broken it down to several questions. After this question is answered and I am able to do this part, I will post next question.

Thanks in advance and happy new year 2020.

What I have tried:

The GetCaseButton_Click that I need to make changes to so I can use DropDownList instead of Combobox.
C#
private async void GetCasesButton_Click(object sender, EventArgs e)
        {
            #region Required Field Validation
            if (CaseNumbersTextBox.Text.Length < 1)
            {
                string myStringVariable = "Case number textbox cannot be empty.";
                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
            }

            ComboboxItem requestorItem = new ComboboxItem();
            requestorItem = (ComboboxItem)RequestorComboBox.SelectedItem;



            ComboboxItem reasonItem = new ComboboxItem();
            reasonItem = (ComboboxItem)ReasonComboBox.SelectedItem;

            if (requestorItem.Value < 1)
            {
                MessageBox.Show("Please select a Requestor.", "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (reasonItem.Value < 1)
            {
                MessageBox.Show("Please select a Reason.", "Search Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
               
               
                return;
            }
            #endregion

            #region Parse case number entries
            string userEnteredCaseNumbers = CaseNumbersTextBox.Text;

            userEnteredCaseNumbers = userEnteredCaseNumbers.Replace("\r", ",");
            userEnteredCaseNumbers = userEnteredCaseNumbers.Replace("\n", ",");
            while (userEnteredCaseNumbers.Contains(",,"))
                userEnteredCaseNumbers = userEnteredCaseNumbers.Replace(",,", ",");

            List<string> userEnteredCaseNumberList = new List<string>();
            userEnteredCaseNumberList = userEnteredCaseNumbers.Split(',').Where(x => x.Length > 0).ToList();
            userEnteredCaseNumberList = userEnteredCaseNumberList.Select(s => s.Trim()).ToList();
            #endregion
}
Posted
Updated 3-Jan-20 16:36pm
v2
Comments
Christian Graus 3-Jan-20 22:37pm    
If you're making a new app. why are you using ASP.NET? Why didn't you tag your question as ASP.NET? If you are not up to date to use a framework like Angular, you should at least be using MVC

If you want to change the control, you need to go through the code and change it to work with the new control. There are no shortcuts.

Of course, you have to change the code completely, it's a rewrite anyhow.

You can't show a message box in your back end code.

If you're making a new app. why are you using ASP.NET? Why didn't you tag your question as ASP.NET?

If you want to change the control, you need to go through the code and change it to work with the new control. There are no shortcuts.

Of course, you have to change the code completely, it's a rewrite anyhow.

You can't show a message box in your back end code.
 
Share this answer
 
If you're making a new app. why are you using ASP.NET? Why didn't you tag your question as ASP.NET? If you are not up to date to use a framework like Angular, you should at least be using MVC

If you want to change the control, you need to go through the code and change it to work with the new control. There are no shortcuts.

Of course, you have to change the code completely, it's a rewrite anyhow.

You can't show a message box in your back end code.
 
Share this answer
 
Comments
Member 11403304 8-Jan-20 10:18am    
Thank you Christian. My supervisor does not want me to use what you suggested.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900