ASP.net error. update panel - asp.net

I am getting the below stated error in javascript. This error occurs when i try to cal update panel on button click
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near 'Panel|UpdatePanel1|
<div id="up'.
Here is the UpdatePanel code:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode=Conditional >
<ContentTemplate>
<div style="font-size:10px; font-weight:bold;display:none;" align=center id="up_div" runat=server >Apply Flat Rate to all days
<asp:TextBox ID="txtflatrate" runat="server" Width=40 ></asp:TextBox>
<asp:Button ID="btn_apply" runat="server" Text="Go" UseSubmitBehavior=false OnClick="btn_apply_Click" />
<asp:Table ID="tbl_charges" runat="server" EnableViewState=true>
</asp:Table>
Total: <asp:TextBox ID="txtttlrate" runat="server" ReadOnly="True"></asp:TextBox>
</div>
<div id="div_norates" runat=server visible=false style ="font-size:11px" class="red_font">
<font color='red'>
<center><b>Please make the neccessary changes before <i>creating a booking</i></b></font></CENTER><br/><br/><br/><center>The <i>season </i>for the date period chosen is <i>not set </i><br/> <center> <br/>OR </center> <br/> The <i>room type </i>for the season is <i>not set</i>. <br/><br/><br/>Make neccessary changes in <i>seasons master</i></center>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID=btn_calc EventName=click />
<asp:AsyncPostBackTrigger ControlID=btn_apply EventName=click />
</Triggers>
</asp:UpdatePanel>
I am not able to understand why this error is coming? Can anyone help me sort out this issue?

I believe the aspx markup in incorrect causing the parser error. Check at UpdateMode=Conditional
If that is not the case please ensure that you are not using a Response.Write() in the async postback(see error message).

Related

Error in Window-Control

hi i have some Problem with my Window-Control, if i set the BrowserDialogBox property to True
im becoming an Error Rendering Control - Window1:
"an unhandled exception has occurred object reference not set to an instance of an object."
Synfusion:
<syncfusion:Window ID="Window1" runat="server" Height="200px" Width="250px"
Title="Öffnen" IconImageUrl="~/Images/KBD-Favicon.ico" EnableXHTML="False" BrowserDialogBox="true" EnableTheming="true">
</syncfusion:Window>
I have used Syncfusion window control as like your code, but it is working without any error which you have reported. Post more of your code and we'll see what you done wrong.
<p>
You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&clcid=0x409"
title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Panel ID="Panel1" runat="server">
<syncfusion:Window ID="Window1" runat="server" Height="200px" Width="250px" Title="Öffnen"
IconImageUrl="~/Images/KBD-Favicon.ico" EnableXHTML="False" InitiallyShown="True"
BrowserDialogBox="true" EnableTheming="true">
</syncfusion:Window>
</asp:Panel>
</p>

My modal window is not transferring values to vb.net codebehind

I am getting the username and password to run some scripts
<act:ModalPopupExtender ID="unixLoginMPE" runat="server" TargetControlID="rdoUnix"
PopupControlID="unixPanel" BackgroundCssClass="modalBackground" CancelControlID="unixCancel" OkControlID="unixSubmit"
/>
<asp:Panel ID="unixPanel" runat="server"
CssClass="modalPopup" align="center" Style="display: none">Unix Username: <asp:TextBox ID="unixName" ClientIDMode="Static" runat="server" />
<br />
Unix Password: <asp:TextBox ID="unixPass" runat="server" ClientIDMode="Static" TextMode="Password" />
<br />
<asp:Button ID="unixCancel" runat="server" Text="Cancel" />
<asp:Button ID="unixSubmit" ClientIDMode="Static" runat="server" Text="Submit" OnClientClick="enableRDO()" />
</asp:Panel>
In my codebehind, I'm doing something like this just to test if the values have passed.
Dim UNIXPASSWORD As String = unixPass.text
Dim UNIXUSERNAME As String = unixName.Text
MsgBox(UNIXCOMPUTERNAME)
MsgBox(UNIXUSERNAME)
MsgBox(UNIXPASSWORD)
I do reference a script to enable the radio button. I asked a question to help me with that issue, it is all resolved Radio Button won't stay check if I have a modal window open up when it is selected
<script type="text/javascript">
function enableRDO() {
var cancel = document.getElementById('rdoUnix');
cancel.setAttribute('checked', 'true');
};
</script>
For some reason the values are passing just fine in Google Chrome but not in IE. I've been at this for a few hours and don't know what else to try...or search for
EDIT:
I'm still trying to attempt this. I setup up dummy text boxes which I will hide later on if I can pass to them. I'm still very lost with this...
<asp:TextBox ID="dummyUnixName" runat="server" />
<asp:TextBox ID="dummyUnixPass" runat="server" />
If you aren't performing a postback or an AJAX call, nothing will be passed to the code behind.
During debugging, Console.WriteLine can be redirected to the output window in VS; in production, it's going to go nowhere. A logging solution is often appropriate for a web application which needs to know more of what happened than which page was requested by a user (IIS logs).

Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred

while trying to process some user input which contains characters such as <.
I do want to sanitize this input and allow it to be displayed and be XSS safe.
I'm getting this ajax error even though I haven't reached the the vb code behind to clean up the input.
Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
The input is controlled by a btnNoteSave which is a updatepanel trigger.
<div style="width: 100%; float: left">
<div>
<asp:Button ValidationGroup="valgroup1" ID="btnNoteSave" runat="server" Text="Save"
class="ui-state-default ui-corner-all float-left ui-button" />
</div>
</div>
<div style="width: 100%; float: left">
<asp:UpdatePanel ID="pnlNotes" runat="server">
<ContentTemplate>
<div id="content_container" style="margin-top: 85px">
<asp:Label ID="lblNotes" runat="server"></asp:Label>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnNoteSave" EventName="click" />
</Triggers>
</asp:UpdatePanel>
</div>
I've tried sanitizing my input in the code behind but I'm not even reaching that far. The error is an ajax error that throws when it reaches here.
Protected Sub btnNoteSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNoteSave.Click
....
newnote.Note = Server.HtmlEncode(txtNote.Text)
....
End Sub
Any ideas how to get deal with these issues?
Thanks,
You probably need to add ValidateRequest="false" to the #Page directive of your page (or to the <pages> element in your web.config file. This disables XSS checking by ASP.NET that is triggered when it encountered < > characters.
If you are still getting 500 errors from the PageRequestManager try temporarily moving the controls outside of the UpdatePanel so you can better inspect the runtime error.

ASP.NET Label Inside UpdatePanel Not Updating

I am new to ASP.NET and I'm trying to get a Label to update with some information that is grabbed when I hit a button. The click function is called and returns just fine (I've debugged and stepped through the whole thing). The only thing that doesn't work is where I set the text of the Labels I'm trying to update.
This is the function that gets called on the button click:
Protected Sub submitbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submitbutton.Click
Dim res As String() = query(email1.Text)
If Not res Is Nothing Then
url1.Text = res(0)
date1.Text = res(1)
End If
End Sub
I know it goes into the if and tries to set the text but nothing happens on the client side.
This is the UpdatePanel I have:
<asp:UpdatePanel ID="UpdatePanelSettings" runat="server" UpdateMode="Always" >
<Triggers>
<asp:AsyncPostBackTrigger ControlID="submitbutton" EventName="click" />
</Triggers>
<ContentTemplate>
<table>
<tr>
<td>Emails</td><td>Url Parsed</td><td>Date Created</td>
</tr>
<tr>
<td>
<asp:TextBox runat="server" ID="email1" Width="300" />
</td>
<td>
<asp:Label runat="server" ID="url1" Text="-" />
</td>
<td>
<asp:Label runat="server" ID="date1" Text="-" />
</td>
</tr>
<tr>
<td colspan="3"><asp:Button ID="submitbutton" runat="server" Text="Submit" /></td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
As I said, I know the trigger works because I've stepped through the code when it is called. I know that you also need a ScriptManager, which I have right inside the form element that comes in the Site.Master file (I really just stuck stuff in the default template. It's just a proof of concept project).
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
From all the articles I've found on the web, this should be all I need. One article mentioned having to do things with the Web.Config, but it said that for VS 2005 and I'm using 2010. It mentioned you didn't have to change anything in 2008, so I figured the same was true for 2010. What am I missing that I need to get the labels to update?
I haven't worked with this for a while, but you may need to explicitly call:
UpdatePanelSettings.Update()
At the end of your command.
.
Give it a try anyway.
Can you try removing the section.
<Triggers>
<asp:AsyncPostBackTrigger ControlID="submitbutton" EventName="click" />
</Triggers>
Then change the UpdatePanel by add ChildrenAsTriggers="true" to it.
<asp:UpdatePanel ID="UpdatePanelSettings" runat="server" UpdateMode="Always" ChildrenAsTriggers="true" >
In theory, this should be exactly the same as the way you have it above, but just trying to help you debug it.
1) Is it possible res is two blank items?
2) Is there any other code that touches the two labels (like when the form loads)?

AutoPostBack on CheckBox control sometimes fails

If have the below markup.
<asp:checkbox id="chkTVLic" runat="server" text="TV Licence" oncheckedchanged="chkDocs_CheckChanged"
autopostback="true" CausesValidation="false" />
<asp:panel id="pnlTVLic" runat="server" visible="false">
<div class="toggle-item-link1 document-date">
<asp:panel id="pnlTVLicIssueDate" runat="server">
<p>
Please enter the date of issue
</p>
<div class="fm-req">
<asp:textbox id="txtTVLicIssueDate" cssclass="tb size2" runat="server" onblur="return true;"></asp:textbox>
<cc2:calendarextender id="caleTVLicIssueDate" runat="server" targetcontrolid="txtTVLicIssueDate"
popupbuttonid="ibnTVLicIssueDate" popupposition="BottomLeft" animated="true"
format="dd/MM/yyyy">
</cc2:calendarextender>
<asp:imagebutton id="ibnTVLicIssueDate" runat="server" imageurl="../images/img-calendar-day.png"
alternatetext="Calendar" tooltip="Pick Date" cssclass="date-picker" />
<asp:requiredfieldvalidator id="rfvTVLicIssueDate" CssClass="error" runat="server" controltovalidate="txtTVLicIssueDate"
display="Dynamic" errormessage="Required" setfocusonerror="true" validationgroup="TVLic"></asp:requiredfieldvalidator>
<asp:comparevalidator id="cmvTVLicIssueDate" CssClass="error" runat="server" errormessage="Not a valid date"
controltovalidate="txtTVLicIssueDate" operator="DataTypeCheck" type="Date" setfocusonerror="true"
validationgroup="TVLic" display="Dynamic" cultureinvariantvalues="true"></asp:comparevalidator>
<asp:customvalidator id="cuvTVLicIssueDate12Months" CssClass="error" runat="server" controltovalidate="txtTVLicIssueDate"
validationgroup="TVLic" display="Dynamic" onservervalidate="cuvDocIssueDate12Months_ServerValidate"
errormessage="Document must be less than 12 months old."></asp:customvalidator>
</div>
</asp:panel>
<asp:panel id="pnlTVLicApprove" runat="server">
<asp:LinkButton id="lbnTVLicApprove" runat="server" CssClass="screen-hide"
alternatetext="Confirm TV Licence" tooltip="Confirm TV Licence" Text="OK" CausesValidation="false" OnClick="lbnApproveConfirm_Click" />
<asp:imagebutton id="ibnTVLicApprove" runat="server" imageurl="../images/img-accept-doc-off.png"
alternatetext="Approve" tooltip="Approve" cssclass="approval-btn" causesvalidation="true" validationgroup="TVLic" OnMouseDown="HandleApproveClick('TVLic','lbnTVLicApprove');return false;" OnClientClick="HandleApproveClick('TVLic','lbnTVLicApprove');return false;" />
<span class="approval-label">Accept document:</span></asp:panel>
</div>
</asp:panel>
The app is written in c# but i havn't posted any actual code as all the user code related to this markup seems to work fine.
The problem is the CheckBox chkTVLic has causes validation set to false and autopostback set to true. So whatever happens when i check and uncheck the checkbox it should postback. Most of the time this is exactly what it does and the result is to show and hide pnlTVLic when it is checked and unchecked. However if any on the validators within the panel fire, the checkbox does not cause a postback the first time. It will on all subsequent times but never the first. However it should ALWAYS cause a postback. What could be stopping it. Before someone asks there is no use written client side code, everything is pure .net markup and c# code.
I don't see why it shouldn't postback when you check/uncheck the checkbox, but if the only purpose of that checkbox is to hide/unhide a panel, I would rather do it in javascript. Doing a full postback to the server just for hiding some panel seems really bad.
In javascript you can do this to hide the panel:
document.getElementById('<%=pnlTVLic.ClientID%>').display='none';
And this to show it:
document.getElementById('<%=pnlTVLic.ClientID%>').display='block';
It's going to be so much faster and better. Just put a regular checkbox instead of the ASP.NET one and subscribe to the onclick event.
Sorry, one more comment:
I think you are wrong when you say that the checkbox should ALWAYS cause a postback. No, if one of the validators fires inside the panel, the checkbox will not cause a postback until the condition is satisfied.
This is what I did and it worked.
on checkbox onclick event I disabled all the validation controls and immediately did Page_ClientValidate(); and it worked.

Resources