按钮事件代码背后没有在Azure上触发

时间:2013-02-25 17:36:22

标签: azure azure-table-storage azure-web-sites

我有一个相当简单的单页面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", "");
        }
    }
}

0 个答案:

没有答案