Showing posts with label AJAX. Show all posts
Showing posts with label AJAX. Show all posts

Thursday, May 5, 2011

Can not put more than one ModalPopup control in one page?

To Show one popup Panel from multiple controls, use one ModalPopupExtender bound to an invisible 'dummy' control, then call ModalPopupExtender.Show() from the OnClick Event of each control you wish to show the popup.

This example is most related with control are added inside of the grid view and also add checkboxlist control inside of the ModelPopup.

CSS
.modalBackground {
FILTER: alpha(opacity=70); BACKGROUND-COLOR: #fff; opacity: 0.7px
}
.modalPopup {
BORDER-BOTTOM: #ccc 3px solid; BORDER-LEFT: #ccc 3px solid; PADDING-BOTTOM: 5px; BACKGROUND-COLOR: #fff; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; BORDER-TOP: #ccc 3px solid; BORDER-RIGHT: #ccc 3px solid; PADDING-TOP: 5px;
}



ASPX
 <asp:Button ID="btnFade" runat="server" Text="" visible="true" Width="0"/> 
 <asp:ModalPopupExtender 
BackgroundCssClass="modalBackground" 
DropShadow="true" 
CancelControlID="btnCancel" 
runat="server" 
PopupControlID="pnlModelPopup" 
id="ModalPopupExtender1" 
TargetControlID="btnFade">
</asp:ModalPopupExtender> 
<asp:Panel ID="pnlModelPopup" runat="server" CssClass="modalPopup" style="display:none;"> 
<table >
<tr>
<td>Add / Modify Competencies<br /><br /> </td>
</tr>
<tr>
<td>
<div style="height:200px; border-style:solid; border-width:thin; overflow: auto; width:100%;" runat="server">
<asp:CheckBoxList ID="chklstCompetencies" runat="server"  RepeatColumns="0" >
</asp:CheckBoxList>
</div>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSave" runat="server" Text="Save" /> 
<asp:Button ID="btnCancel" runat="server" Text="Cancel" /> 
</td>
</tr>
</table>


</asp:Panel> 


In Codebehind any event if you want to fire for this ModelPopup then use this.
' show the modal popup
           popupLink_ModalPopupExtender.Show()


If you need to use Save button with some process in Code behind following property need to be deleted from the asp:ModalPopupExtender
OkControlID="btnOk"

Tuesday, April 26, 2011

Sys.WebForms.PageRequestManagerParserErrorException error - ASP.NET Ajax 1.0

Error Message : 
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 '
<!DOCTYPE html PUB'.

Have you ever got these kind of error when you are doing an Async postback using AJAX.NET .Actually If you’ve seen this error, you’ve probably already spent some time to resolve it. Anyway The solution mentioned below is worked for me. 

1) Make sure this in is your web.config
   <httpModules>
      <add name=”ScriptModule” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions,               Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35?/>
   </httpModules>

2) Add this to the to the Page declaration if you’re experiencing some page refresh bugs
   enableEventValidation=”false”


Source : http://weblogs.asp.net/albertpascual/archive/2008/04/22/how-to-fix-sys-webforms-pagerequestmanagerparsererrorexception-in-ajax-1-0.aspx


If you’ve found alternatives to this problem or our suggested solution isn’t working for you, please feel free to comment below.

Wednesday, April 6, 2011

'Sys' is undefined - ASP.NET AJAX

When I was using ASP.NET 2.0 along with Ajax Extensions 1.0. I received this error ‘Sys’ is undefined error message every time I used an Ajax control.

Wondering why, I search in internet and hope that I will find one of the solution. After several trial and error finally I can find the solution and it work just fine for me.
Why this error?
This error occurs specifically when you try upgrading your existing ASP.NET 2.0 Applications to AJAX by using the ASP.NET AJAX controls like UpdatePanel, etc., The common cause for this error is that you havent updated the Web.Config file of the application to enable the runtime understand ASP.NET AJAX. Let me explain a little more.

When you install ASP.NET AJAX your Visual Studio 2005 gets the toolbox updated with ASP.NET AJAX Server side controls like ScriptManager, ScriptManagerProxy, UpdatePanel, UpdateProgress etc., You already have your existing ASP.NET 2.0 application pages and you can add ScriptManager, UpdatePanel and other controls from Toolbox to your pages. When you run the page, you would get 'Sys' is undefined javascript error. The reason being that, your web.config of the existing ASP.NET 2.0 application misses certain settings that require to be added to make it understand the ASP.NET AJAX Server side controls like UpdatePanel, UpdateProgress etc.,

How to Solve the error ?
To solve the error we need to modify web.config file.
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>