TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Cassie Mod
NA
488
70.1k
textboxvalue in postback is gone
Jul 19 2017 10:11 AM
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) {
//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();
}
}
});
<% } %>
});
</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
{
//TODO: ik moet nog kijken hoe ik mezelf een een feature kan geven.
if
(PortalApplication == null || currentUser == null || Features.CallForwardingNotAvailable)
return
;
// if it is no postback set the radiobutton
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
{
// get the selected value
var optionIsTurnedOff = CallForwardingNotAvailableOption.SelectedIndex == 0;
if
(optionIsTurnedOff)
{
var test = forwardToNewPhoneNumberTextBox.Text;
// empty somehow
// value is set to 'Off'...turn on
// validate everything
var submitError = CompleetApplication.Validate(Page,
"ForwardingNotReachableValidationGroup"
);
// here it keeps crashing because the value of the postback is null
if
(!string.IsNullOrEmpty(submitError))
return
;
// check if textbox isn't empty
if
(forwardToNewPhoneNumberTextBox.Visible && string.IsNullOrEmpty(forwardToNewPhoneNumberTextBox.Text))
{
showFailureText(
"Telefoonnummer is verplicht"
);
return
;
}
//Get the trimmed phonenumber
var phonenumber = forwardToNewPhoneNumberTextBox.Text;
char
[] charsToTrim = {
' '
,
'\t'
};
phonenumber = phonenumber.Trim(charsToTrim);
//Get userId
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
{
//set visiblilty dialogpanel to false and set the ForwardToPanel visibility on true
CallForwardingNotAvailableDialogPanel.Visible =
false
;
ForwardToPanel.Visible =
true
;
// set values to textbox etc
forwardToPhoneNumberTextBox.Text = phonenumber;
}
}
else
{
// value is set to 'On'...turn off
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)
{
//Set visisbility based on coditions
var isActivated = CallForwardingNotAvailableOption.SelectedIndex == 1;
CallForwardingNotAvailableDialogPanel.Visible = isActivated;
// check if it is active or not, if so.. deactivate
if
(isActivated)
return
;
var userId = Request.QueryString[
"userId"
];
NumberLogic.UserCallForwardingNotReachableModify(_requestId, _sessionId, jSessionId, userId, string.Empty,
false
);
}
private
void
SetNumberNotAvalaibleSwitch()
{
// Create the request to get the value of the radiobuttonlist from technic service
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();
}
// Set the response to the radioButton
CallForwardingNotAvailableOption.SelectedIndex = Convert.ToInt32(callForwardingNotReachableMessage.callForwardingNotReachable.isActive);
}
}
}
Reply
Answers (
1
)
about webconfig file
Error when publishing Migrated ASP.Net web application with