1

我有一个相当简单的单页 Web 应用程序,我已经在本地进行了全面测试。此应用程序是一个简单的表单提交,数据存储在 Azure 表存储容器中。我有一个用于提交按钮的代码隐藏函数,我正在执行服务器端验证,并在弹出窗口中显示消息。

在我的本地机器上一切正常,包括所有数据存储和检索回 Azure。将站点发布到 Azure 后,代码隐藏将不会触发,并且站点本身也不会出现任何错误。有任何想法吗?

布赖恩

请查看以下所有代码:

<form id="form1" runat="server">
    <telerik:RadWindowManager ID="DefaultWindowMgr" runat="server"></telerik:RadWindowManager>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>

    <div id="main" style="width:1024px; height:650px; margin-left:auto; margin-right:auto; background-image:url(../Images/earthBG.png);">
        <div id="left" style="width:500px;float:left;left:5px;margin-left:auto;margin-right:auto;">
            <asp:Image ID="Image1" runat="server" ImageAlign="Middle" ImageUrl="~/Images/TRACLogo.png" />
            <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/dashboardGlobe.png" ImageAlign="Middle" />
        </div>
        <div id="right" style="width:500px;float:right;top:75px;position:relative;">
            <p>Some kind of Welcome Text needs to go here.</p>
            <table id="RiskFormTable" style="width:100%;padding:5px;">
                <tr>
                    <td style="text-align:right"><asp:Label ID="LblCompany" runat="server" Text="Company Name:"></asp:Label></td>
                    <td style="text-align:left"><telerik:RadTextBox ID="TxtCompany" runat="server" Width="220px"></telerik:RadTextBox></td>
                </tr>
                <tr>
                    <td style="text-align:right"><asp:Label ID="LblEmail" runat="server" Text="Email Address of POC:"></asp:Label></td>
                    <td style="text-align:left"><telerik:RadTextBox ID="TxtEmail" runat="server" Width="220px"></telerik:RadTextBox></td>
                </tr>
                <tr>
                    <td style="text-align:right"><asp:Label ID="LblCountries" runat="server" Text="What countries do you do business in?"></asp:Label></td>
                    <td style="text-align:left">
                        <telerik:RadListBox ID="LstCountries" runat="server" DataSortField="name" DataSourceID="XMLCountriesSource" DataTextField="name" DataValueField="score" Height="118px" SelectionMode="Multiple" Sort="Ascending" Width="220px" CausesValidation="False"></telerik:RadListBox>
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right"><asp:Label ID="LblPrimary" runat="server" Text="What is your primary customer segment?"></asp:Label></td>
                    <td style="text-align:left">
                        <telerik:RadComboBox ID="DDLPrimary" runat="server" Width="220px" DataSourceID="XMLSegmentsSource" DataTextField="name" DataValueField="value" CausesValidation="False"></telerik:RadComboBox>
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right"><asp:Label ID="LblSecondary" runat="server" Text="What is your secondary customer segment?"></asp:Label></td>
                    <td style="text-align:left">
                        <telerik:RadComboBox ID="DDLSecondary" runat="server" Width="220px" DataSourceID="XMLSegmentsSource" DataTextField="name" DataValueField="value" CausesValidation="False"></telerik:RadComboBox>
                    </td>
                </tr>
                <tr>
                    <td style="text-align:right" colspan="2">
                        <telerik:RadButton ID="BtnSubmit" runat="server" Text="Submit" SingleClick="true" OnClick="BtnSubmit_Click" CausesValidation="False"></telerik:RadButton>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>

这是后面的代码:

using System;
using System.Configuration;
using TRACERiskLibrary.Entities;
using TRACERiskLibrary.Managers;

namespace TRACERisk
{
    public partial class Default2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// This function will get fired when a user submits the Risk Assessment data. It will verify that all of the 
        /// data is accurate and then will save the entry to the Azure Table that is found within the web.config file.
        /// If any of the data is inaccurate or there is a problem with the saving of the data, the error will be
        /// displayed to the user within the RadWindowManager Alert window.
        /// </summary>
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            String azureconn = ConfigurationManager.ConnectionStrings["traceRiskAzure"].ConnectionString;
            String azuretable = ConfigurationManager.AppSettings["AzureTable"];

            if (TxtEmail.Text.CompareTo("") == 0 || TxtEmail.Text.IndexOf('@') < 0 || TxtEmail.Text.IndexOf('.') < 0)
            {
                DefaultWindowMgr.RadAlert("You must enter in a valid Email Address for this submission to be valid. Please try again.", 400, 250, "Risk Survey Submission Error", "");
                return;
            }

            DellRiskEntity entity = new DellRiskEntity(TxtEmail.Text);

            if (TxtCompany.Text.CompareTo("") == 0)
            {
                DefaultWindowMgr.RadAlert("You must enter in a Company Name for this submission to be valid. Please try again.", 400, 250, "Risk Survey Submission Error", "");
                return;
            }
            else
                entity.Company = TxtCompany.Text;

            entity.PrimaryBus = DDLPrimary.SelectedItem.Text;
            entity.PrimaryScore = (Int32) Decimal.Parse(DDLPrimary.SelectedValue);
            entity.SecondaryBus = DDLSecondary.SelectedItem.Text;
            entity.SecondaryScore = (Int32) Decimal.Parse(DDLSecondary.SelectedValue);

            // Verify that the user entered in at least one country of business, if not throw up an error message and stop processing. 
            Int32 countryscore = 0;
            if (LstCountries.SelectedItems.Count == 0)
            {
                DefaultWindowMgr.RadAlert("Please select one or more Countries for which you do business before submitting.", 400, 250, "Risk Survey Submission Error", "");
                return;
            }
            else
            {
                for (int i = 0; i < LstCountries.SelectedItems.Count; i++)
                {
                    entity.Countries.Add(LstCountries.SelectedItems[i].Text);
                    if (Int32.Parse(LstCountries.SelectedItems[i].Value) > countryscore)
                        countryscore = Int32.Parse(LstCountries.SelectedItems[i].Value);
                }
            }
            entity.CountryScore = countryscore;
            entity.TotalScore = entity.PrimaryScore + entity.SecondaryScore + entity.CountryScore;

            if (entity.TotalScore < 11)
                entity.TierLevel = "Tier 1";
            else if (entity.TotalScore < 21)
                entity.TierLevel = "Tier 2";
            else
                entity.TierLevel = "Tier 3";

            // Process the actual saving of the Risk Assessment within the Azure Table
            if (RiskManager.SaveEntry(entity, azureconn, azuretable))
                DefaultWindowMgr.RadAlert("Your Risk Assessment has been Successfully submitted.", 400, 250, "Risk Survey Submitted", "");
            else
                DefaultWindowMgr.RadAlert("There is a record within the Risk Assessment associated with this email address. Please enter new Risk Assessment Data.", 400, 250, "Risk Survey Submission Error", "");
        }
    }
}
4

0 回答 0