Using MaskedEditExtender results in runtime error - c#

I am struggling with using the AJAX Control Toolkit in my ASP.NET code.
I downloaded and imported the dll files from the website and try to follow the instructions,...
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
... inserted a Script Manager
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
and put the ajax MaskEditExtender under the text box that I want to check on:
<asp:TextBox ID="ind_customerRevenue" MaxLength="20" runat="server"></asp:TextBox>
<ajaxtoolkit:MaskedEditExtender ID="TextBox1_MaskedEditExtender" runat="server"
CultureAMPMPlaceholder="" CultureCurrencySymbolPlaceholder=""
CultureDateFormat="" CultureDatePlaceholder="" CultureDecimalPlaceholder=""
CultureThousandsPlaceholder="" CultureTimePlaceholder="" Enabled="True"
Mask="99/99/9999" MaskType="Date" TargetControlID="ind_customerRevenue">
</ajaxtoolkit:MaskedEditExtender>
But when I debug the side it says:
0x800a138f - Microsoft JScript runtime error: 'Sys.Extended.UI' is null or not an object
What am I missing out? I cannot find an answer somehow. Thank you.

Use the ToolkitScriptManager instead of the default ScriptManager.
replace
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
with
<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>

Related

UpdatePanel cause error: PageRequestManagerServerErrorException

I have a page that works fine with multiple a grid and multiple buttons. The page works fine until I add an asp:UpdatePanel. Then I get the following message pushing any of my buttons:
Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in a correct format.
There is no javascript on the page just straight html.
Here is the page:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPages/Site.Master" AutoEventWireup="true"
CodeBehind="TestUpdatePanel.aspx.cs" Inherits="ASCWeb.TestUpdatePanel" %>
<asp:Content ID="mHeadContent" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="mBodyContent" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel ID="pnlUpdate" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtUser" runat="server" />
<asp:ImageButton ID="btnAdd" runat="server" ImageUrl="~/Images/Add.png" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
If I take the TextBox out, it works fine. Nothing is in the code behind.
What would cause this?
Thanks
As per experience, I only encounter that exception when calling Javascript from codebehind, like when using ScriptManager.RegisterClientScriptBlock() to call window.alert(), for instance. But for this issue, I think this resolves it: http://forums.asp.net/t/1823287.aspx/2/10.

ModalPopupExtender Error

i want to popup ModalPopupExtender in button click, but when i run my code and click on the button then ModalPopupExtender is not popup even i used all the required AjaxControlToolkit references for this
my code is following :
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<asp:Panel ID="Panel1" runat="server" BackColor="#CC3300">
hello...
</asp:Panel>
<asp:Button ID="Button1" runat="server" Text="click here" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel1" TargetControlID="Button1">
</asp:ModalPopupExtender>
</div>
</form>
i am using the visual studio 2008 Pro., .Net Framework 3.5 and for Ajax i used AjaxControlToolkit.dll(3.5.60919.0)
sir, plz give me solution for this..
it can be your tags, try ajaxToolkit instead of asp tag
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="Panel1" TargetControlID="Button1">
</ajaxToolkit:ModalPopupExtender>
I believe your workaround lies here:
unknown server tag modalpopupextender
The error is related to the use of a master page in your site and was reportedly going to be fixed in a Visual Studio service pack (as of 2007, but not yet as of VS 2010 SP1). There is a simple workaround though that works for some folks (and did for me):
Open the master page first, then open the page with your ModalPopupExtender in it.
Need to include the below line in your aspx page at the top .
Just change the version according to your's.
<%# Register TagPrefix="asp" Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit, Version=4.1.7.1005, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" %>

Missing files from Ajax control Toolkit manifest error?`

Hello this is the first time I have used Ajax. I added ajax to my visual studio 2010 toolbox and pulled a calendar over my text box. When I run my site I get this error.
MissingManisfestResourceException
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "AjaxControlToolkit.Properties.Resources.NET4.resources" was correctly embedded or linked into assembly "AjaxControlToolkit" at compile time, or that all the satellite assemblies required are loadable and fully signed.
Now it says I am missing ExtenderControlBase, Where can I get that?
My code of my calendar:
<asp:TextBox ID="txtBday" runat="server"
style="z-index: 1; left: 327px; top: 436px" Height="22px"></asp:TextBox><asp:CalendarExtender
ID="Birthday" runat="server"
onclientdateselectionchanged="CheckDateEalier" TargetControlID="txtBday"
PopupButtonID="btnBirth" PopupPosition="TopRight" >
</asp:CalendarExtender>
<asp:ImageButton ID="btnBirth" runat="server"
ImageUrl="~/images/calendaricon.jpg" />
It appears you forgot to reference the assembly at the top of your content file and need a script manager here is a working example hope it helps.
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox ID="TB" runat="server" />
<asp:CalendarExtender ID="C" runat="server" TargetControlID="TB">
</asp:CalendarExtender>
</form>
</body>
</html>

How to use form with method="post" in asp.net web form

I am using ajax toolkit asyncFileUpload control
I had problem that my server side events does not fired and found this posts Hidden/Shown AsyncFileUpload Control Doesn't Fire Server-Side UploadedComplete Event
I inserted my uploader inside form and with this attributes enctype="multipart/form-data" method="post"
This uploader is inside my webs form which is inside master page
After adding this attributes i got this error
A page can have only one server-side Form tag.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A page can have only one server-side Form tag.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
And here is my web form
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<form id="Form1" enctype="multipart/form-data" method="post" action="target_url"
runat="server">
<div id="Div1" runat="server">
Just some time to make sure that the page doesn't get reloaded after uploading:
<%=DateTime.Now %><br />
<ajaxToolkit:AsyncFileUpload ID="FileUpload" runat="server" OnUploadedComplete="FileUpload_UploadCompleted"
OnClientUploadComplete="FileUpload_ClientUploadCompleted" OnClientUploadError="uploadError"
OnLoad="FileUpload_OnLoad" />
<asp:Image runat="server" ID="imgUpload" src="" />
<asp:Label runat="server" ID="lblerror" Text="" />
</div>
</form>
</asp:Content>
Your MasterPage already has a form element. Nested forms aren't allowed...
I don't know much about the ajaxToolkit:AsyncFileUpload but, since it is a server control, it should change the parent forms properties. Have you tried removing the form like the code below?
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<div id="Div1" runat="server">
Just some time to make sure that the page doesn't get reloaded after uploading:
<%=DateTime.Now %><br />
<ajaxToolkit:AsyncFileUpload ID="FileUpload" runat="server" OnUploadedComplete="FileUpload_UploadCompleted"
OnClientUploadComplete="FileUpload_ClientUploadCompleted" OnClientUploadError="uploadError"
OnLoad="FileUpload_OnLoad" />
<asp:Image runat="server" ID="imgUpload" src="" />
<asp:Label runat="server" ID="lblerror" Text="" />
</div>
</asp:Content>
Another Possible Solution:
"Pop" a "modal" form that just contains your form with the file upload control. This will remedy the nested forms issue. But, it does changed the functionality.
As a very dirty hack try adding adding a <form></form> in front of your form, and take the runat="server" out of your nested form.
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
**<form></form>**
<form id="Form1" enctype="multipart/form-data" method="post" action="target_url"
>
<div id="Div1" runat="server">
Just some time to make sure that the page doesn't get reloaded after uploading:
<%=DateTime.Now %><br />
<ajaxToolkit:AsyncFileUpload ID="FileUpload" runat="server" OnUploadedComplete="FileUpload_UploadCompleted"
OnClientUploadComplete="FileUpload_ClientUploadCompleted" OnClientUploadError="uploadError"
OnLoad="FileUpload_OnLoad" />
<asp:Image runat="server" ID="imgUpload" src="" />
<asp:Label runat="server" ID="lblerror" Text="" />
</div>
</form>
</asp:Content>
In the past this has worked for me - when forced to work with WebForms. I don't know why but I find that quite a lot with WebForms.
You really should switch to MVC if you want to write code like this however. Even if this does work it's not what I'd call a solution. WebForms just isn't designed to do this.

AJAX Firing OnUnload Twice

All, thanks in advance.
I'm using the ASP.NET AJAX Control Toolkit to create 2 CascadingDropDowns. The problem is the base OnUnload is firing twice when I load the page. Any idea how to stop this? See code snippets below.
Update: I've determined a workaround but if anyone knows of a way to suppress, I would be interested to hear!
<%# Page Language="C#" AutoEventWireup="true"
CodeFile="dataentry.aspx.cs"
Inherits="dataentry"
EnableEventValidation="false" %>
<ajaxToolkit:ToolkitScriptManager EnablePartialRendering="true"
runat="server"
ID="ScriptManager1" />
<asp:DropDownList ID="drpDate" runat="server"></asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server"
TargetControlID="drpDate"
Category="Date"
PromptText="Please select a date"
ServicePath="SchedulerService.asmx"
ServiceMethod="GetSchedulerDates"
UseContextKey="true" />
<asp:DropDownList ID="drpTime" runat="server"></asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown2" runat="server"
TargetControlID="drpTime"
ParentControlID="drpDate"
PromptText="Please select a time"
ServiceMethod="GetSchedulerTimesForDate"
ServicePath="SchedulerService.asmx"
Category="Time"
UseContextKey="true" />

Categories