Showing posts with label extensions. Show all posts
Showing posts with label extensions. Show all posts

Wednesday, March 28, 2012

Page_Validators in AJAX.NET problem.

Good day,

Using ASP.NET 2.0 AJAX Extensions 1.0 (1.0.61025) I am getting different output from my dev environment and another Windows 2003 server. It is causing a null reference exception because of the absence of some script, as follows.

A page that demonstrates the problem. Essentially a Textbox with a Validator in an UpdatePanel. The Textbox is hidden in a partial page update and the validator isn't removed from Page_Validators, leading to a null reference exception. Here it is.

1<%@dotnet.itags.org. Page Language="C#" %>
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<title>AJAX Test</title>
5<script runat="server">
6 protected void Button1_Click(object sender, EventArgs e)
7 {
8 TextBox1.Visible = false;
9 }
10</script>
11</head>
12<body>
13 <form id="form1" runat="server">
14 <div>
15
16 <asp:ScriptManager ID="ScriptManager1" runat="server" />
17 <asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>
18 <asp:TextBox ID="TextBox1" runat="server" />
19 <asp:RequiredFieldValidator ID="req" runat="server" ControlToValidate="TextBox1">Bad!</asp:RequiredFieldValidator>
20 <br />
21 <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" />
22 </ContentTemplate></asp:UpdatePanel>
23
24 </div>
25 </form>
26</body>
27</html>
Here is the output from the dev environment that works:
1<html xmlns="http://www.w3.org/1999/xhtml">
2<head>
3<title>AJAX Test</title>
45</head>
6<body>
7 <form name="form1" method="post" action="ajaxTest.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="form1">
8<div>
9<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
10<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
11<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEzMDMxMDUwMDhkZDuvWiPpfDn3oBIdbrlUSDkq1FdR" />
12</div>
1314<script type="text/javascript">
15<!--
16var theForm = document.forms['form1'];
17if (!theForm) {
18 theForm = document.form1;
19}
20function __doPostBack(eventTarget, eventArgument) {
21 if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
22 theForm.__EVENTTARGET.value = eventTarget;
23 theForm.__EVENTARGUMENT.value = eventArgument;
24 theForm.submit();
25 }
26}
27// -->2829</script>
303132<script src="/WebResource.axd?d=aw9IrFUp2_oQ8Owgb8KfHw2&t=633198061661875000" type="text/javascript"></script>
333435<script src="/ScriptResource.axd?d=CKqJO5pnLiMiiKIAPSjUhlVSq_XssPmgCzQ3imV6c-ZI8ou-jtF3g7zNM6zAzFuwj0cj4E-Yc9RTfjMvluxK4g2&t=633198061661875000" type="text/javascript"></script>
36<script src="/ScriptResource.axd?d=cKz-vvqLo1ehaWyVHnXCamccZCS0TLr_WkNiTAu40bnCXSUBzVyHwrKIRYpIqnRFj0bnuLFtFlIG1uLE2IU0HlTdJFkwvyWnrxefUsmR0881&t=633278094321250000" type="text/javascript"></script>
37<script src="/ScriptResource.axd?d=cKz-vvqLo1ehaWyVHnXCamccZCS0TLr_WkNiTAu40bnCXSUBzVyHwrKIRYpIqnRFj0bnuLFtFlIG1uLE2IU0HjrmGHRUhUO2-euEh4H2gbI1&t=633278094321250000" type="text/javascript"></script>
38<script type="text/javascript">
39<!--
40function WebForm_OnSubmit() {
41if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
42return true;
43}
44// -->45</script>
4647 <div>
4849 <script type="text/javascript">
50//<![CDATA[51Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));
52Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1'], [], [], 90);
53//]]>
54</script>
5556 <div id="UpdatePanel1">
57
58 <input name="TextBox1" type="text" id="TextBox1" />
59 <span id="req" style="color:Red;visibility:hidden;">Bad!</span>
60 <br />
61 <input type="submit" name="Button1" value="" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("Button1", "", true, "", "", false, false))" id="Button1" />
62
6364</div>
6566 </div>
67
68<script type="text/javascript">
69<!--
70var Page_Validators = new Array(document.getElementById("req"));
71// -->72</script>
7374<script type="text/javascript">
75<!--
76var req = document.all ? document.all["req"] : document.getElementById("req");
77req.controltovalidate = "TextBox1";
78req.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
79req.initialvalue = "";
80// -->81</script>
8283<div>
8485<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwKV1JT3DQLs0bLrBgKM54rGBh9lq902q1zs4nZQoQSzXWrrFvC2" />
86</div>
8788<script type="text/javascript">
89<!--
90var Page_ValidationActive = false;
91if (typeof(ValidatorOnLoad) == "function") {
92 ValidatorOnLoad();
93}
9495function ValidatorOnSubmit() {
96 if (Page_ValidationActive) {
97 return ValidatorCommonOnSubmit();
98 }
99 else {
100 return true;
101 }
102}
103// -->104</script>
105
106<script type="text/javascript">
107<!--
108Sys.Application.initialize();
109110document.getElementById('req').dispose = function() {
111 Array.remove(Page_Validators, document.getElementById('req'));
112}
113// -->114</script>
115</form>
116</body>
117</html>
118

Here is output from a different server that fails.

1<html xmlns="http://www.w3.org/1999/xhtml">2<head>3<title>AJAX Test</title>45</head>6<body>7 <form name="form1" method="post" action="ajaxTest.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="form1">8<div>9<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />10<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />11<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEzMDMxMDUwMDhkZBFseLlnE6oRW+2WytSmHIxuhR3k" />12</div>1314<script type="text/javascript">15<!--16var theForm = document.forms['form1'];17if (!theForm) {18 theForm = document.form1;19}20function __doPostBack(eventTarget, eventArgument) {21 if (!theForm.onsubmit || (theForm.onsubmit() != false)) {22 theForm.__EVENTTARGET.value = eventTarget;23 theForm.__EVENTARGUMENT.value = eventArgument;24 theForm.submit();25 }26}27// -->2829</script>303132<script src="/WebResource.axd?d=y79a8WX0nIrEh3fkGSsX9A2&t=633281399937474336" type="text/javascript"></script>333435<script src="/WebResource.axd?d=w26mxAmgRXp-rT77oPfALL7gzYUT-X6oWLHzd_D6LjY1&t=633281399937474336" type="text/javascript"></script>36<script src="/ScriptResource.axd?d=wZTJCSpVLa8cXWFJgmiuXX-hnAsgClz1-CgGif5xa_-p3CzrOtmsIfh3Y28aQcYFVC5wnr2IJhBHoh2c9Zc0Ch0RynufR4TLZTewW0cBhsc1&t=633281590101841744" type="text/javascript"></script>37<script src="/ScriptResource.axd?d=wZTJCSpVLa8cXWFJgmiuXX-hnAsgClz1-CgGif5xa_-p3CzrOtmsIfh3Y28aQcYFVC5wnr2IJhBHoh2c9Zc0CrgGo9Nt84M88yWLG3iczXI1&t=633281590101841744" type="text/javascript"></script>38<script type="text/javascript">39<!--40function WebForm_OnSubmit() {41if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;42return true;43}44// -->45</script>4647 <div>4849 <script type="text/javascript">50//<![CDATA[51Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('form1'));52Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tUpdatePanel1'], [], [], 90);53//]]>54</script>5556 <div id="UpdatePanel1">5758 <input name="TextBox1" type="text" id="TextBox1" />59 <span id="req" style="color:Red;visibility:hidden;">Bad!</span>60 <br />61 <input type="submit" name="Button1" value="" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("Button1", "", true, "", "", false, false))" id="Button1" />626364</div>6566 </div>6768<script type="text/javascript">69<!--70var Page_Validators = new Array(document.getElementById("req"));71// -->72</script>7374<script type="text/javascript">75<!--76var req = document.all ? document.all["req"] : document.getElementById("req");77req.controltovalidate = "TextBox1";78req.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";79req.initialvalue = "";80// -->81</script>8283<div>8485<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwKvmrnGBwLs0bLrBgKM54rGBh5nv4YQrwGF0j7OWce2dFyfGsmj" />86</div>8788<script type="text/javascript">89<!--90var Page_ValidationActive = false;91if (typeof(ValidatorOnLoad) == "function") {92 ValidatorOnLoad();93}9495function ValidatorOnSubmit() {96 if (Page_ValidationActive) {97 return ValidatorCommonOnSubmit();98 }99 else {100 return true;101 }102}103// -->104</script>105106<script type="text/javascript">107<!--108Sys.Application.initialize();109// -->110</script>111</form>112</body>113</html>114
The working machine is a dev machine with a long history of messing around.The failing machine is a freshly installed Windows 2003 install with only critical updates, .Net Framework 2.0, Ajax Extensions.I uninstalled and reinstalled Ajax Extensions on the dev machine using the same msi.
I am unable to figure out what is different in the configuration.

Any suggestions would be tremendous!

Thanks,

Craig


Validation controls, which includes theBaseCompareValidator,BaseValidator,CompareValidator,CustomValidator,RangeValidator,RegularExpressionValidator,RequiredFieldValidator, andValidationSummary control are not compatible with UpdatePanel

See it here

http://weblogs.asp.net/scottgu/archive/2007/01/25/links-to-asp-net-ajax-1-0-resources-and-answers-to-some-common-questions.aspx

You can downlaod compatible ersion of validators from here

http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx


Thanks muchly! :)

Wednesday, March 21, 2012

Parser Error Message: Could not load file or assembly AjaxControlToolkit or one of its dep

Hi,

I am using ASP.Net 2.0 with AJAX Extensions 1.0. And one of my aspx was using 2 of the ajaxtoolkit namely the ModalPopupExtender and RoundedCornersExtender. But why is it that when I will access the page from the web server the error below will display on the page. It's really frustrating because there's no problem when running locally in my machine thru Visual Web Developer 2005 Express Edition.

I hope you could help me figuring the problem.

Thanks

Error message:

Server Error in '/' Application.

Parser Error

Description:An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message:Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The system cannot find the file specified.

Source Error:

Line 1: <%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>Line 2: <%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>Line 3: Line 4: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


Source File:/pfadmin/test.aspx Line:2

Assembly Load Trace: The following information can be helpful to determine why the assembly 'AjaxControlToolkit' could not be loaded.

WRN: Assembly binding logging is turned OFF.To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.Note: There is some performance penalty associated with assembly bind failure logging.To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].



Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

You need to deploy the AjaxControlTookit (DLL) to the server (in your bin directory or in the GAC).

-Damien


Hi hifiger2004,

You can just include the AjaxControlToolkit.dll into the BIN folder of your website/webapplication. There is no need to deploy it to the GAC. (Maybe you don't have the right to do that.)

Also check if some plain ajax functionallity works on the webserver!!! For example: A simple updatePanel holding a datetime.now, and a button to trigger it. Note that the ajax functionality must work in order to use the AjaxControl Toolkit.

Please let me know how it worked out!
Kind regards,
Wim


You have to include the AjaxControlToolkit.dll into the bin folder of your webapplication

Let me know if this helpful to you

partial page update in a usercontrol on a master page

OK, I've installed AJAX Extensions, watched the tutorial video and tried to use the partial page update as follows: I have a user control which contains hyperlinks for paging back and forth and a datalist which displays the current page of products: <asp:UpdatePanelID="UpdatePanel1"runat="server"> <ContentTemplate> <asp:HyperLinkID="hLink_Previous"CssClass="paging_Text"Visible="false"runat="server">Previous</asp:HyperLink> <asp:LabelID="label_Paging"CssClass="paging_Text"Visible="false"runat="server"/> <asp:HyperLinkID="hLink_Next"CssClass="paging_Text"Visible="false"runat="server">Next</asp:HyperLink> <asp:DataListID="dataList_Products"RepeatColumns="2"RepeatDirection="Horizontal"runat="server"EnableViewState="False"OnItemCommand="dataList_Products_ItemCommand"> <ItemTemplate> <tableclass="dataList_Products_Table"cellpadding="0"align="left"> <trclass="dataList_Products_Table_Row"> <tdalign=centerclass="dataList_Products_Table_Cell_1"> <ahref='Product.aspx?P=<%# Eval("ProductID")%>'> <imgclass="small_Image"src='ProductImages/<%# Eval("Image1FileName")%>'/> </a> </td> <tdclass="dataList_Products_Table_Cell_2"> <aclass="product_Name"href='Product.aspx?P=<%# Eval("ProductID")%>'> <%# Eval("Name")%> </a> <br/> <spanclass="product_Description"> <%# Eval("Description")%> <br/> <br/> Price: </span> <spanclass="product_Price"> <%# Eval("Price","{0:C}")%> </span> <br/> <asp:ButtonID="btn_AddToCart"Text="Add to Cart"CssClass="small_Button_Text"CommandArgument='<%# Eval("ProductID")%>'runat="server"/> </td> </tr> </table> </ItemTemplate> </asp:DataList> </ContentTemplate></asp:UpdatePanel> I use this within the contentPlaceHolder on the Master page. I want only this bit to update when I navigate between pages but looking at the triggers collection, I can only see the datalist and ScriptManager controls - how do I hook into the previous and next page hyperlinks and their onClick event to enable the page update ? Thanks AR

Hi,

HyperLink control doesn't have click event.

You can use LinkButton control that has a similar layout like hyperlink to achieve so.

Hope this helps.