HI ive got the following error. ive got a aspx page. with some controls. wich can be filled in. However on my postback the value of a forwardToNewPhoneNumberTextBox is gone. so nog it crashes on the regularExpressionValidator.
How can i fix this ??
- <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CallForwardingNotAvailableControl.ascx.cs" Inherits="OneXS.Orion.FrontOffice.Compleet.Portal.Controls.CallForwardingNotAvailableControl" %>
- <asp:UpdatePanel ID="CallForwardingNotAvailableUpdatePanel" runat="server" UpdateMode="Conditional">
- <ContentTemplate>
- <%--eror row--%>
- <div class="row error">
- <asp:Panel runat="server" ID="FailureTextPanel" Visible="False" class="submit-summary error-summary">
- <asp:Literal ID="FailureTextLiteral" runat="server" />
- </asp:Panel>
- </div>
- <%--tekst--%>
- <div class="row">
- <div class="part fourth">
- <asp:Label ID="isActivatedLabel" runat="server" AssociatedControlID="CallForwardingNotAvailableOption"
- CssClass="label-xl">Doorschakelen niet bereikbaar</asp:Label>
- </div>
- <%--switch om "Doorschakelen" waarde weer te geven--%>
- <div class="part sixth switch last">
- <asp:RadioButtonList ID="CallForwardingNotAvailableOption" runat="server" CssClass="optionOnOff" RepeatLayout="Flow"
- RepeatColumns="3">
- <asp:ListItem Value="Off" class="switch-off" Text=" "> </asp:ListItem>
- <asp:ListItem Value="On" class="switch-on" Text=" "> </asp:ListItem>
- </asp:RadioButtonList>
- </div>
- <div class="part third last">
- <asp:Panel ID="ForwardToPanel" runat="server" Visible="false" DefaultButton="forwardToPhoneNumberEditLinkButton">
- <asp:Label ID="forwardToPhoneNumberLabel" Width="50px" runat="server" AssociatedControlID="forwardToPhoneNumberTextBox"
- CssClass="label-xs">Naar :</asp:Label>
- <asp:TextBox ID="forwardToPhoneNumberTextBox" runat="server" ReadOnly="true"></asp:TextBox>
- <asp:Button ID="forwardToPhoneNumberEditLinkButton" runat="server" CausesValidation="false"
- OnClick="CallForwardingNotAvailablePhoneNumberEdit_Click" CssClass="button-s" Text="wijzig" />
- <asp:Button ID="forwardToPhoneNumberSaveLinkButton" runat="server" OnClick="CallForwardingNotAvailableSave_Click"
- Visible="false" CssClass="button-s" Text="opslaan" />
- </asp:Panel>
- </div>
- </div>
- <div class="row">
- <div id="CallForwardingNotAvailableDialog" title="Waar wilt u naar doorschakelen bij niet bereikbaar?">
- <asp:Panel ID="CallForwardingNotAvailableDialogPanel" runat="server">
- <asp:Panel runat="server" ID="dialogFailureTextPanel" Visible="False" class="submit-summary error-summary">
- <asp:Literal ID="dialogFailureTextLiteral" runat="server" />
- </asp:Panel>
- <asp:Label ID="forwardToNewPhoneNumberLabel" runat="server" CssClass="label-s" AssociatedControlID="forwardToNewPhoneNumberTextBox">Naar:</asp:Label>
- <asp:TextBox ID="forwardToNewPhoneNumberTextBox" runat="server" CssClass="input-xxl"></asp:TextBox>
- <asp:RequiredFieldValidator ID="forwardToNewPhoneNumberTextBoxRequiredFieldValidator"
- runat="server" ControlToValidate="forwardToNewPhoneNumberTextBox" ErrorMessage="*"
- ForeColor="Red" BorderColor="Red" SetFocusOnError="true" CssClass="error-span"
- ValidationGroup="ForwardingNotReachableValidationGroup" />
- <asp:RegularExpressionValidator ID="forwardToNewPhoneNumberRegularExpressionValidator"
- ErrorMessage="*" runat="server" ControlToValidate="forwardToNewPhoneNumberTextBox"
- ValidationGroup="ForwardingNotReachableValidationGroup"></asp:RegularExpressionValidator>
- </asp:Panel>
- </div>
- <asp:Button ID="CallForwardingNotAvailableButton" runat="server" UseSubmitBehavior="false"
- ValidationGroup="callForwardingAlwaysValidationGroup" OnClick="CallForwardingNotAvailableSave_Click"
- Style="display: none;" />
- </div>
- </ContentTemplate>
- <Triggers>
- <asp:AsyncPostBackTrigger ControlID="CallForwardingNotAvailableButton" EventName="Click" />
- <asp:AsyncPostBackTrigger ControlID="forwardToPhoneNumberEditLinkButton" EventName="Click" />
- <asp:AsyncPostBackTrigger ControlID="forwardToPhoneNumberSaveLinkButton" EventName="Click" />
- </Triggers>
- </asp:UpdatePanel>
-
- <script type="text/javascript">
- $(document).ready(function () {
-
- ApplyJQueryUIInControl();
- Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
-
- function EndRequestHandler(sender, args) {
-
- }
-
- function ApplyJQueryUIInControl() {
-
- $("#<%= CallForwardingNotAvailableOption.ClientID %>").buttonset();
-
- $("#CallForwardingNotAvailableDialog").dialog({
- resizable: false,
- modal: true,
- autoOpen: false,
- show: "fade",
- closeOnEscape: false,
- hide: "fade",
- buttons: {
- "> Ok": function () {
- $("#<%= CallForwardingNotAvailableButton.ClientID %>").click();
- },
- "> Annuleren": function () {
- $("#<%= CallForwardingNotAvailableOption.ClientID %>_0").attr("checked", "checked");
- $("#<%= CallForwardingNotAvailableOption.ClientID %>").buttonset("refresh");
- $(this).dialog("close");
- }
- }
- });
-
- }
- <% if (string.IsNullOrEmpty(forwardToPhoneNumberTextBox.Text))
- {%>
-
- <%-- $('#CallForwardingNotAvailableDialog').keypress(function (e) {
- if (e.keyCode === $.ui.keyCode.ENTER) {
- $("#<%= CallForwardingNotAvailableButton.ClientID %>").click();
- }
- });--%>
-
-
-
- $("#<%= CallForwardingNotAvailableOption.ClientID %>").on("click", function (e) {
-
- e.preventDefault(); // this needed to be done otherwise the event is fired twice
-
-
- var list = document.getElementById("<%= CallForwardingNotAvailableOption.ClientID %>");
- var inputs = list.getElementsByTagName("input");
- var selected;
- for (var i = 0; i < inputs.length; i++) {
- if (inputs[i].checked) {
- selected = inputs[i];
- break;
- }
- }
-
-
- if (selected) {
-
- var selectedValue = selected.value;
- if (selectedValue === "Off") {
-
- $("#CallForwardingNotAvailableDialog").dialog("open");
- $("#<%= forwardToNewPhoneNumberTextBox.ClientID %>").focus();
- } else {
-
- $("#<%= CallForwardingNotAvailableButton.ClientID %>").click();
- }
- }
-
- });
- <% } %>
- });
- </script>
code behind:
- using System;
- using System.Web;
- using OneXS.Orion.BackOffice.Technic.ServiceAgent.Model;
- using OneXS.Orion.Framework;
- using OneXS.Orion.FrontOffice.Compleet.BusinessLogic;
- using OneXS.Orion.FrontOffice.Compleet.Service;
-
- namespace OneXS.Orion.FrontOffice.Compleet.Portal.Controls
- {
- public partial class CallForwardingNotAvailableControl : CompleetControl
- {
- private static Guid _requestId;
- private Guid _sessionId;
- public string jSessionId;
- public User currentUser;
- public Features Features { get; set; }
-
- protected void Page_Load(object sender, EventArgs e)
- {
- _sessionId = Guid.Parse(HttpContext.Current.Session["BWSESSION"].ToString());
- _requestId = Guid.NewGuid();
- jSessionId = PortalApplication.User.jSessionId;
-
- try
- {
-
- if (PortalApplication == null || currentUser == null || Features.CallForwardingNotAvailable)
- return;
-
-
- if (!IsPostBack)
- {
- SetNumberNotAvalaibleSwitch();
- }
-
- forwardToNewPhoneNumberTextBoxRequiredFieldValidator.Enabled = true;
- forwardToNewPhoneNumberRegularExpressionValidator.ValidationExpression = ValidatorConstants.INTEGER_REGEX;
- forwardToNewPhoneNumberRegularExpressionValidator.ErrorMessage = ValidatorConstants.INTEGER_MESSAGE;
- forwardToNewPhoneNumberRegularExpressionValidator.Text = ValidatorConstants.INTEGER_MESSAGE;
- }
- catch (Exception ex)
- {
- PortalApplication.HandleException(ex);
- showFailureText();
- }
- }
-
- protected void CallForwardingNotAvailablePhoneNumberEdit_Click(object sender, EventArgs e)
- {
- CallForwardingNotAvailableDialogPanel.Visible = true;
- ForwardToPanel.Visible = false;
- }
-
- protected void CallForwardingNotAvailableSave_Click(object sender, EventArgs e)
- {
- try
- {
-
- var optionIsTurnedOff = CallForwardingNotAvailableOption.SelectedIndex == 0;
-
- if (optionIsTurnedOff)
- {
- var test = forwardToNewPhoneNumberTextBox.Text;
-
-
-
- var submitError = CompleetApplication.Validate(Page, "ForwardingNotReachableValidationGroup");
- if (!string.IsNullOrEmpty(submitError))
- return;
-
-
- if (forwardToNewPhoneNumberTextBox.Visible && string.IsNullOrEmpty(forwardToNewPhoneNumberTextBox.Text))
- {
- showFailureText("Telefoonnummer is verplicht");
- return;
- }
-
-
- var phonenumber = forwardToNewPhoneNumberTextBox.Text;
- char[] charsToTrim = { ' ', '\t' };
- phonenumber = phonenumber.Trim(charsToTrim);
-
-
- var userId = Request.QueryString["userId"];
- var isActive = CallForwardingNotAvailableOption.SelectedIndex == 1;
-
- var callForwardingNotReachableMessage = CallForwardingNotAvailableOption.SelectedIndex == 1
- ? NumberLogic.UserCallForwardingNotReachableModify(_requestId, _sessionId, jSessionId, userId,
- phonenumber, isActive)
- : NumberLogic.UserCallForwardingNotReachableModify(_requestId, _sessionId, jSessionId, userId,
- null, false);
-
- if (callForwardingNotReachableMessage.errorCode != 0 ||
- !string.IsNullOrEmpty(callForwardingNotReachableMessage.errorMessage))
- {
- showFailureText();
- }
- else
- {
-
- CallForwardingNotAvailableDialogPanel.Visible = false;
- ForwardToPanel.Visible = true;
-
-
- forwardToPhoneNumberTextBox.Text = phonenumber;
- }
- }
- else
- {
-
- var userId = Request.QueryString["userId"];
- NumberLogic.UserCallForwardingNotReachableModify(_requestId, _sessionId, jSessionId, userId, string.Empty, false);
- }
- }
- catch (Exception ex)
- {
- PortalApplication.HandleException(ex);
- showFailureText();
- }
- }
-
- private void showFailureText(string failureText = "Er is iets fout gegaan tijdens het uitvoeren van uw opdracht.")
- {
- FailureTextLiteral.Text = failureText;
- FailureTextPanel.Visible = true;
- PortalApplication.EndRequest();
- }
-
- protected void CallForwardingNotAvailableOption_SelectedIndexChanged(object sender, EventArgs e)
- {
-
- var isActivated = CallForwardingNotAvailableOption.SelectedIndex == 1;
- CallForwardingNotAvailableDialogPanel.Visible = isActivated;
-
-
- if (isActivated) return;
-
- var userId = Request.QueryString["userId"];
- NumberLogic.UserCallForwardingNotReachableModify(_requestId, _sessionId, jSessionId, userId, string.Empty, false);
- }
-
- private void SetNumberNotAvalaibleSwitch()
- {
-
- var userId = Request.QueryString["userId"];
- var callForwardingNotReachableMessage = NumberLogic.GetUserCallForwardingNotReachable(_requestId, _sessionId, jSessionId, userId);
- var errorCode = callForwardingNotReachableMessage.errorCode;
- var errorMessage = callForwardingNotReachableMessage.errorMessage;
- if (errorCode != 0 || !string.IsNullOrEmpty(errorMessage))
- {
- showFailureText();
- }
-
-
- CallForwardingNotAvailableOption.SelectedIndex = Convert.ToInt32(callForwardingNotReachableMessage.callForwardingNotReachable.isActive);
- }
- }
- }