Skip to content
Loading
textboxvalue in postback is gone  
  •         class="row">  
  •             "CallForwardingNotAvailableDialog" title="Waar wilt u naar doorschakelen bij niet bereikbaar?">  
  •                 "CallForwardingNotAvailableDialogPanel" runat="server">  
  •                     "server" ID="dialogFailureTextPanel" Visible="False" class="submit-summary error-summary">  
  •                         "dialogFailureTextLiteral" runat="server" />  
  •                       
  •                     "forwardToNewPhoneNumberLabel" runat="server" CssClass="label-s" AssociatedControlID="forwardToNewPhoneNumberTextBox">Naar:  
  •                     "forwardToNewPhoneNumberTextBox" runat="server" CssClass="input-xxl">  
  •                     "forwardToNewPhoneNumberTextBoxRequiredFieldValidator"  
  •                         runat="server" ControlToValidate="forwardToNewPhoneNumberTextBox" ErrorMessage="*"  
  •                         ForeColor="Red" BorderColor="Red" SetFocusOnError="true" CssClass="error-span"  
  •                         ValidationGroup="ForwardingNotReachableValidationGroup" />  
  •                     "forwardToNewPhoneNumberRegularExpressionValidator"  
  •                         ErrorMessage="*" runat="server" ControlToValidate="forwardToNewPhoneNumberTextBox"  
  •                         ValidationGroup="ForwardingNotReachableValidationGroup">  
  •                   
  •               
  •             "CallForwardingNotAvailableButton" runat="server" UseSubmitBehavior="false"  
  •                 ValidationGroup="callForwardingAlwaysValidationGroup" OnClick="CallForwardingNotAvailableSave_Click"  
  •                 Style="display: none;" />  
  •           
  •       
  •       
  •         "CallForwardingNotAvailableButton" EventName="Click" />  
  •         "forwardToPhoneNumberEditLinkButton" EventName="Click" />  
  •         "forwardToPhoneNumberSaveLinkButton" EventName="Click" />  
  •       
  •   
  •   
  • "text/javascript">  
  •     $(document).ready(function () {  
  •           
  •         ApplyJQueryUIInControl();  
  •         Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);  
  •   
  •         function EndRequestHandler(sender, args) {  
  •             //ApplyJQueryUIInControl();  
  •         }  
  •   
  •         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();  
  •                     }  
  •             });--%>  
  •   
  •         //$("#CallForwardingNotAvailableDialog").parent().appendTo($("#<%= CallForwardingNotAvailableUpdatePanel.ClientID %>:first"));  
  •   
  •         $("#<%= CallForwardingNotAvailableOption.ClientID %>").on("click", function (e) {  
  •   
  •             e.preventDefault();  // this needed to be done otherwise the event is fired twice
  •   
  •             // check if option is 'Off'  
  •             var list = document.getElementById("<%= CallForwardingNotAvailableOption.ClientID %>"); //Client ID of the radiolist  
  •             var inputs = list.getElementsByTagName("input");  
  •             var selected;  
  •             for (var i = 0; i < inputs.length; i++) {  
  •                 if (inputs[i].checked) {  
  •                     selected = inputs[i];  
  •                     break;  
  •                 }  
  •             }  
  •   
  •             // radio option is selected  
  •             if (selected) {  
  •                 // remove later  
  •                 var selectedValue = selected.value;  
  •                 if (selectedValue === "Off") {  
  •                     // show dialog   
  •                     $("#CallForwardingNotAvailableDialog").dialog("open");  
  •                     $("#<%= forwardToNewPhoneNumberTextBox.ClientID %>").focus();  
  •                 } else {  
  •                     // trigger click event  
  •                     $("#<%= CallForwardingNotAvailableButton.ClientID %>").click();  
  •                 }  
  •             }  
  •               
  •             });  
  •         <% } %>  
  •     });  
  •  
  •  code behind:
     
    1. using System;  
    2. using System.Web;  
    3. using OneXS.Orion.BackOffice.Technic.ServiceAgent.Model;  
    4. using OneXS.Orion.Framework;  
    5. using OneXS.Orion.FrontOffice.Compleet.BusinessLogic;  
    6. using OneXS.Orion.FrontOffice.Compleet.Service;  
    7.   
    8. namespace OneXS.Orion.FrontOffice.Compleet.Portal.Controls  
    9. {  
    10.     public partial class CallForwardingNotAvailableControl : CompleetControl  
    11.     {  
    12.         private static Guid _requestId;  
    13.         private Guid _sessionId;  
    14.         public string jSessionId;  
    15.         public User currentUser;  
    16.         public Features Features { get; set; }  
    17.   
    18.         protected void Page_Load(object sender, EventArgs e)  
    19.         {  
    20.             _sessionId = Guid.Parse(HttpContext.Current.Session["BWSESSION"].ToString());  
    21.             _requestId = Guid.NewGuid();  
    22.             jSessionId = PortalApplication.User.jSessionId;  
    23.   
    24.             try  
    25.             {  
    26.                 //TODO: ik moet nog kijken hoe ik mezelf een een feature kan geven.   
    27.                 if (PortalApplication == null || currentUser == null || Features.CallForwardingNotAvailable)  
    28.                     return;  
    29.   
    30.                 // if it is no postback set the radiobutton  
    31.                 if (!IsPostBack)  
    32.                 {  
    33.                     SetNumberNotAvalaibleSwitch();  
    34.                 }  
    35.   
    36.                 forwardToNewPhoneNumberTextBoxRequiredFieldValidator.Enabled = true;  
    37.                 forwardToNewPhoneNumberRegularExpressionValidator.ValidationExpression = ValidatorConstants.INTEGER_REGEX;  
    38.                 forwardToNewPhoneNumberRegularExpressionValidator.ErrorMessage = ValidatorConstants.INTEGER_MESSAGE;  
    39.                 forwardToNewPhoneNumberRegularExpressionValidator.Text = ValidatorConstants.INTEGER_MESSAGE;  
    40.             }  
    41.             catch (Exception ex)  
    42.             {  
    43.                 PortalApplication.HandleException(ex);  
    44.                 showFailureText();  
    45.             }  
    46.         }  
    47.   
    48.         protected void CallForwardingNotAvailablePhoneNumberEdit_Click(object sender, EventArgs e)  
    49.         {  
    50.             CallForwardingNotAvailableDialogPanel.Visible = true;  
    51.             ForwardToPanel.Visible = false;  
    52.         }  
    53.   
    54.         protected void CallForwardingNotAvailableSave_Click(object sender, EventArgs e)  
    55.         {  
    56.             try  
    57.             {  
    58.                 // get the selected value   
    59.                 var optionIsTurnedOff = CallForwardingNotAvailableOption.SelectedIndex == 0;  
    60.   
    61.                 if (optionIsTurnedOff)  
    62.                 {  
    63.                     var test = forwardToNewPhoneNumberTextBox.Text;// empty somehow  
    64.   
    65.                     // value is set to 'Off'...turn on   
    66.                     // validate everything  
    67.                     var submitError = CompleetApplication.Validate(Page, "ForwardingNotReachableValidationGroup");  // here it keeps crashing because the value of the postback is null  
    68.                     if (!string.IsNullOrEmpty(submitError))  
    69.                         return;  
    70.   
    71.                     // check if textbox isn't empty  
    72.                     if (forwardToNewPhoneNumberTextBox.Visible && string.IsNullOrEmpty(forwardToNewPhoneNumberTextBox.Text))  
    73.                     {  
    74.                         showFailureText("Telefoonnummer is verplicht");  
    75.                         return;  
    76.                     }  
    77.   
    78.                     //Get the trimmed phonenumber  
    79.                     var phonenumber = forwardToNewPhoneNumberTextBox.Text;  
    80.                     char[] charsToTrim = { ' ''\t' };  
    81.                     phonenumber = phonenumber.Trim(charsToTrim);  
    82.   
    83.                     //Get userId  
    84.                     var userId = Request.QueryString["userId"];  
    85.                     var isActive = CallForwardingNotAvailableOption.SelectedIndex == 1;  
    86.   
    87.                     var callForwardingNotReachableMessage = CallForwardingNotAvailableOption.SelectedIndex == 1  
    88.                         ? NumberLogic.UserCallForwardingNotReachableModify(_requestId, _sessionId, jSessionId, userId,  
    89.                             phonenumber, isActive)  
    90.                         : NumberLogic.UserCallForwardingNotReachableModify(_requestId, _sessionId, jSessionId, userId,  
    91.                             null, false);  
    92.   
    93.                     if (callForwardingNotReachableMessage.errorCode != 0 ||  
    94.                         !string.IsNullOrEmpty(callForwardingNotReachableMessage.errorMessage))  
    95.                     {  
    96.                         showFailureText();  
    97.                     }  
    98.                     else  
    99.                     {  
    100.                         //set visiblilty dialogpanel to false and set the ForwardToPanel visibility on true  
    101.                         CallForwardingNotAvailableDialogPanel.Visible = false;  
    102.                         ForwardToPanel.Visible = true;  
    103.   
    104.                         // set values to textbox etc  
    105.                         forwardToPhoneNumberTextBox.Text = phonenumber;  
    106.                     }  
    107.                 }  
    108.                 else  
    109.                 {  
    110.                     // value is set to 'On'...turn off   
    111.                     var userId = Request.QueryString["userId"];  
    112.                     NumberLogic.UserCallForwardingNotReachableModify(_requestId, _sessionId, jSessionId, userId, string.Empty, false);  
    113.                 }  
    114.             }  
    115.             catch (Exception ex)  
    116.             {  
    117.                 PortalApplication.HandleException(ex);  
    118.                 showFailureText();  
    119.             }  
    120.         }  
    121.   
    122.         private void showFailureText(string failureText = "Er is iets fout gegaan tijdens het uitvoeren van uw opdracht.")  
    123.         {  
    124.             FailureTextLiteral.Text = failureText;  
    125.             FailureTextPanel.Visible = true;  
    126.             PortalApplication.EndRequest();  
    127.         }  
    128.   
    129.         protected void CallForwardingNotAvailableOption_SelectedIndexChanged(object sender, EventArgs e)  
    130.         {  
    131.             //Set visisbility based on coditions  
    132.             var isActivated = CallForwardingNotAvailableOption.SelectedIndex == 1;  
    133.             CallForwardingNotAvailableDialogPanel.Visible = isActivated;  
    134.   
    135.             // check if it is active or not, if so.. deactivate  
    136.             if (isActivated) return;  
    137.   
    138.             var userId = Request.QueryString["userId"];  
    139.             NumberLogic.UserCallForwardingNotReachableModify(_requestId, _sessionId, jSessionId, userId, string.Empty, false);  
    140.         }  
    141.   
    142.         private void SetNumberNotAvalaibleSwitch()  
    143.         {  
    144.             // Create the request to get the value of the radiobuttonlist from technic service  
    145.             var userId = Request.QueryString["userId"];  
    146.             var callForwardingNotReachableMessage = NumberLogic.GetUserCallForwardingNotReachable(_requestId, _sessionId, jSessionId, userId);  
    147.             var errorCode = callForwardingNotReachableMessage.errorCode;  
    148.             var errorMessage = callForwardingNotReachableMessage.errorMessage;  
    149.             if (errorCode != 0 || !string.IsNullOrEmpty(errorMessage))  
    150.             {  
    151.                 showFailureText();  
    152.             }  
    153.   
    154.             // Set the response to the radioButton  
    155.             CallForwardingNotAvailableOption.SelectedIndex = Convert.ToInt32(callForwardingNotReachableMessage.callForwardingNotReachable.isActive);  
    156.         }  
    157.     }  

     

    1 Reply

    Know the answer? Post it — somebody with the same question will find it here.