Showing posts with label working. Show all posts
Showing posts with label working. Show all posts

Wednesday, March 28, 2012

calling javascript functions

I am working on an ajax web page which has several controls including a ScriptManager control and the ajax Timer control. When the timer fires a tick I want the server side to perform some calculations and then call a client script function with the results. The client script will then do something with the results.

Also, I want to call another javascript function when I click a button.

I'm a bit rusty with javascript, so I'd like to see examples on how to make this work.

What and where exactly you want to do?

When the timer fires, I want the server to generate (calculate) a pair of integers (or possibly an array of pairs) and call a javascript function on the client side passing those numbers. The client will then "plot" points on a graphics window using some built-in drawing java functions I have. The timer will probably fire several times a second. The client does not need to make any calls to the server.

When a button is clicked, I want the server to call another javascript function (passing no arguments) which will erase the graphics window. The timer continues firing.

I have other buttons, to start and stop the timer, sliders to change the timer rate and other parameters, checkboxes and radio buttons which also affect the calculations, etc. All I need help with is making the client calls and passing the data. Is the ScriptManager useful in that respect? By the way, I'm kind of "new" in java.

I've seen scenarios where client calls server, and server calls the client back with a reply. However, can the server just call the client repeatedly? Or does the timer control act as the client-to-server caller?


Yo can use for calling javascript function

Registering Custom Script

from ScriptManager

http://ajax.asp.net/docs/mref/O_T_System_Web_UI_ScriptManager_RegisterClientScriptBlock.aspx

For calling server side function use web services..


Actually, what I need to do requires "COMET", a form of "reverse AJAX". Is there an easy way to emplement COMET in ASP.Net? When the user clicks the "start" button, the server needs to begin "firing" pairs of numbers at the client at a steady rate (several times a second) until the user clicks the "stop" button.


Hi,

According to theclient life cycle, you can hook an event handler to theloadevent which will be fired every time an partial postback returns. Then invoke your graphical jscript function in it. For instance:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<script runat="server"
</script
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Timer ID="Timer1" runat="server" Interval="1000">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
<input id="time" />
</form
<script type="text/javascript">
function draw(){
var dt = new Date();
$get("time").value = dt.toString();
}

Sys.Application.add_load(ApplicationLoadHandler)

function ApplicationLoadHandler(sender, args)
{
draw(); // invoke your graphical function instead
}
</script
</body>
</html>


Thanks, but I didnt get it what does this do ?


 <script type="text/javascript">
function draw(){
var dt = new Date();
$get("time").value = dt.toString();
}

Sys.Application.add_load(ApplicationLoadHandler)

function ApplicationLoadHandler(sender, args)
{
draw(); // invoke your graphical function instead
}
</script>


This is a javascript function with no usefulness at all, just for demostration purpose. You need to invoke what you really need here.

I need the server to send a pair of numbers to the client each time it fires.


You can expose the method of sending numbers as a web service on the server.

Then invoke it at client side.

Please read this:

http://ajax.asp.net/docs/tutorials/ConsumingWebServicesWithAJAXTutorial.aspx

calling external webservice

Hi all,

I'am still working with the beta 2 version of Ms Ajax and i have question about making a call to an external webservice. Is it possible to make a call to an external webservice from javascript without a bridge file in RC. If not will it be possible in the future?

Thanks in advance!

In the current release, it's not possible to call an external web service without the bridge (seehttp://ajax.asp.net/docs/mref/P_System_Web_UI_ServiceReference_Path.aspx for more info) and for RTM this will probably continue like this, as you can see in this whitepaperhttp://ajax.asp.net/files/AspNet_AJAX_CTP_to_RC_Whitepaper.aspx#link4, in the client networking feature.

Regards,

MaĆ­ra


Hi Maire,

Thanks for your response!!

Regards


Actually you can call an external web service! Check out this article:

http://www.xml.com/pub/a/2005/12/21/json-dynamic-script-tag.html

I hope it helps,

Bogdan


Hi Bogdanb,

Thanks for your reply. Your example is an AJAX example and not a MS AJAX example. In AJAX it is possible to do a call to a webservice directly. MS AJAX simplefies this call for me. I want to use MS AJAX and call an external webservice. Right now i'am using a bridge file to make it work. i wanted to know if this will change in the future.

Regards,

Calling a WebService in another website on the same domain (Solved)

Hi all.

I'd been messing about with Atlas this week and after some banging of head against wall managed to get the basics working. I then found myself wanting to build a modular application consisting of multiple web services, but was getting no joy calling web servies in external solutions (projects) - I had the usual stuff reported in Fiddler suggesting I add [WebOperationAttribute(true, ResponseFormatMode.Json, true)] to my web method.

Not having done any webservice coding before this was all a bit bewildering but with some persistence I managed to get it all working.

If anyone else is having trouble here's what you do:

1) Make sure your remote web service is also an Atlas application.

2) In the Web.Config file of the remote webservice add the following under the <system.web> section:

<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" type="Microsoft.Web.Services.ScriptHandlerFactory" validate="false"/>
<add verb="*" path="iframecall.axd" type="Microsoft.Web.Services.IFrameHandler" validate="false"/>
</httpHandlers>

3) In your WebService class file include a reference to the Microsoft.Web.Services namespace:

Imports Microsoft.Web.Services

4) On your WebMethod add the following WebOperationAttribute:

<WebOperationAttribute(True, ResponseFormatMode.Json, True)>

So, it should look like:

<WebMethod()> _
<WebOperationAttribute(True, ResponseFormatMode.Json, True)> _
Public Function HelloWorld(ByVal strValue As String) As String
Return strValue
End Function

(some examples I found (including that of Fiddler I think) had square brackets surrounding the WebOperationAttribute which confused the issue)

5) In your calling application, reference the remote service as follows:

<atlas:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<atlas:ServiceReference Path="http://localhost/AtlasTest2/Test.asmx" />
</Services>
</atlas:ScriptManager>


...and that should work.

Hope this helps. Any comments/suggestions welcome.

Ben

Hi Ben,

In theory, you should not have to go through the iframehandler if your other web service is in the same domain. Try simply havingpath="/AtlasTest2/Test.asmx" without thehttp://localhost part.

The reason you saw square brackets in some samples is that it is the C# syntax for attributes, while you're using VB.

David

Monday, March 26, 2012

Call web service in Javascript

I used to use Atlas for calling web service in Javascirpt and everything works fine. After I upgrade to Ajax beta1 it stopped working. The error message is the web service class is undefined. I have updated web.config file manually. I also tested this by creating a new ajax toolkit web site. The following is the code. It give me the same error? Anyone can help? I also get a error message for one page I had never met before with Atlas. The error message is error:Sys.ArgumentException: Value must not be null for controls and Behaviors. parameter name:element.

Thanks.

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="Microsoft.Web.Configuration.ScriptingSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="webServices" type="Microsoft.Web.Configuration.ScriptingWebServicesSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="Microsoft.Web.Configuration.ScriptingJsonSerializationSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="profileService" type="Microsoft.Web.Configuration.ScriptingProfileServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="authenticationService" type="Microsoft.Web.Configuration.ScriptingAuthenticationServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
</controls>
<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</tagMapping>
</pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpHandlers>
<httpModules>
<add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
<microsoft.web>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
<!--
<jsonSerialization maxJsonLength="500">
<converters>
<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
</converters>
</jsonSerialization>
-->
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
-->
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
and modified in Atlas applications, you need to add each property name to the setProperties and
getProperties attributes. -->
<!--
<profileService enabled="true"
setProperties="propertyname1,propertyname2"
getProperties="propertyname1,propertyname2" />
-->
</webServices>
</scripting>
</microsoft.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-ISAPI-2.0"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>
</configuration>
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService {

public WebService () {

//Uncomment the following line if using designed components
//InitializeComponent();
}

[WebMethod]
public string HelloWorld() {
return "Hello World";
}

}

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" >
<Services >
<asp:ServiceReference Path="~/WebService.asmx" />
</Services>
</asp:ScriptManager>
<div>
<script type="text/javascript">
function GetString()
{
strResult = WebService.HelloWord(alert(),alert());
alert(strResult);
}
</script>
<input type="button" id="Button1" onclick="GetString();" value="Click" />
</div>
</form>
</body>
</html>

Hi there, I think you forgot to append [Microsoft.Web.Script.Services.ScriptService] attribute in your webservice class. For example of simple webservice call, see myblog post orajax.asp.net docs.


Got it. Thanks for your advice. It is not mentioned in the migration manual. I also find you can not use AJAX controls on hidden field, at least it is true for AutoComplete. This caused the problem I mentioned in the first post. Hope this will help someone.

Call to WebService not working...

I am getting this error 'Microsoft JScript runtime error: 'wsWeatherFeed' is undefined. It's just a basic call to a webservice via the asp:ScriptManager tag. Can someone help me point out what I might be doing wrong?

.Aspx file:

<scriptlanguage="javascript"type="text/javascript">

function fnImgMouseOver(e){

wsWeatherFeed.set_timeout(40000);

wsWeatherFeed.fnGetWeatherData(e,callback_fnImgMouseOver,fnGetWeatherDataError);

}

function callback_fnImgMouseOver(result){

alert(result);

}

function fnGetWeatherDataError(err){

alert("Here is the error: " + err.error);

}

</script>

<further down>

<asp:ScriptManagerID="ScriptManager1"runat="server">

<Services>

<asp:ServiceReferencePath="wsWeatherFeed.asmx"/>

</Services>

</asp:ScriptManager>

.Asmx file

<%@dotnet.itags.org.WebServiceLanguage="C#"CodeBehind="~/App_Code/wsWeatherFeed.cs"Class="wsWeatherFeed" %>

.cs WebService file:

using System;

using System.Web;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Collections;

using System.Xml;

using System.Xml.XPath;

using System.Xml.Xsl;

[WebService(Namespace ="http://tempuri.org/")]

[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]

[System.Web.Script.Services.ScriptService()]

publicclasswsWeatherFeed :WebService {

public wsWeatherFeed () {

//Uncomment the following line if using designed components

//InitializeComponent();

}

[WebMethod]

protectedstring fnGetWeatherData(String strData)

{

return strData

}

}

I got this to work with VB.Net but I guess I just lost something along the way, can anyone provide a clue?

J

Ok I got it. The reason why my js couldnt get to my webservice class was that my web service method fnGetWeatherData was intially set to 'protected' instead of 'public'.

Anyway, I didnt want anyone to spend any time troubleshooting this if I can answer it quick enough myself.

J

Saturday, March 24, 2012

Call a JS function on AJAX update (instead of using UpdateProgress control)

The atlas:UpdateProgress control is nice, but an app I am working on already has a "loading..." image that is displayed using JavaScript (displayLoader(), and hideLoader() to hide) whenever a "non-Atlas" postback is invoked, and when the page initially starts loading.

I am looking for an way to call these functions whenever an Atlas postback is made so I can use this functionality for both types of postback. Is there an way to do this with client script, rather than creating a custom version of the UpdateProgress control?

Regards,
David

You should check out the samples on the client atlas section.

You can handle the different events to create your own custom progress indicator.


hello.

once again, search the atlas discussion an suggestion forum. there you'll find 1 or 2 posts that show how to handle the propertychanged event of the pagerequestmanager in order to handle the start and end of a partial atlas postback with jscript.


Great, those keywords have helped turn up some good results. I was previously searching both here and search engines for terms relating to "custom atlas updateprogress control" and didn't have much luck.

Thanks for pointing me in the right direction.
Regards,
David

CalenderExtender not working when TextBox is not empty

Hi

I was testing the CalendarExtender control and it worked fine but only if the TextBox was empty. I'm guessing this is a bug...! Does anyone know how to fix it?

Cheers

I hv d same problem

Calender

not working if applyinf the format to

Calender

<

cc2:CalendarExtenderID="CalendarExtender1"runat="server"PopupButtonID="Image1"TargetControlID="txtdob"Format="dd-MMM-yyyy"></cc2:CalendarExtender><asp:TextBoxID="txtdob"runat="server"></asp:TextBox><asp:ImageID="Image1"runat="server"ImageUrl="~/images/Calendar_scheduleHS.png"/>

and behind code

txtdob.Text = myDate.

ToString("dd-MMM-yyyy");

if txtdob is already filled during page load

Wednesday, March 21, 2012

CalendarExtender, ValidatorCallout, or FilteredTextboxExtender Causing Error in Partial Po

Hello everyone,

I really enjoy working with the Controls Tookit. The ValidatorCallout is especially nice to use. I'm trying to use a drop-down list to cause a partial postback in an updatepanel. When the ddl selectionchanges, it is supposed to pull database information and then populate some textfields. These textfields have been wrapped in sometimes all three of the extenders listed above. When I change the selection on the ddl, I get a Javascript error:

Line: 5909 Char: 12 Sys.ArgumentUndefinedException: value cannot be undefined. Parameter name: id.

I know this is in one of the javascript files that get attached to my code when it gets built. I'm trying to figure out what's the root cause. Do you think the page is trying to validate the empty textfields? The validatorcallouts are not firing, if that is the case. I've attached my aspx code. Let me know if the code-behind would be useful as well.

Thanks for any help you can provide.

<asp:ScriptManager runat="server" ID="smModify" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <table> <tr> <td colspan="3" style="font-size: x-large"><b>Common Fields</b></td> </tr> <tr> <td class="spacer"> </td> <td align="right">Branch Number:</td> <td> <asp:DropDownList ID="ddlSharedBranches" runat="server" AutoPostBack="True"> </asp:DropDownList><%--<asp:TextBox ID="txtBranchNumber" runat="server" MaxLength="5"></asp:TextBox> <ajax:FilteredTextBoxExtender ID="ftxteBranchNumber" runat="server" TargetControlID="txtBranchNumber" FilterType="Numbers"> </ajax:FilteredTextBoxExtender> <asp:RequiredFieldValidator ID="rfvBranchNumber" runat="server" display="none" ErrorMessage="Please enter data in the form #####." ControlToValidate="txtBranchNumber"></asp:RequiredFieldValidator> <ajax:ValidatorCalloutExtender ID="vceBranchNumber" runat="server" TargetControlID="rfvBranchNumber" HighlightCssClass="validateCallout"> </ajax:ValidatorCalloutExtender>--%> </td> </tr> <tr> <td class="spacer"> </td> <td align="right">Branch Name:</td> <td> <asp:TextBox ID="txtBranchName" runat="server" MaxLength="30"></asp:TextBox> <asp:RequiredFieldValidator ID="rfvBranchName" runat="server" display="none" ErrorMessage="Please enter the Branch's Name here." ControlToValidate="txtBranchName"></asp:RequiredFieldValidator> <ajax:ValidatorCalloutExtender ID="vceBranchName" runat="server" TargetControlID="rfvBranchName" HighlightCssClass="validateCallout"> </ajax:ValidatorCalloutExtender> </td> </tr> <tr> <td class="spacer"> </td> <td align="right">Bank:</td> <td> <asp:DropDownList ID="ddlBank" runat="server"> <asp:ListItem Text="Carolina First" Value="1"></asp:ListItem> <asp:ListItem Text="Mercantile Bank" Value="6"></asp:ListItem> </asp:DropDownList> </td> </tr> <tr> <td colspan="3"> <asp:CheckBox ID="cbTOSS" runat="server" AutoPostBack="true" />Modify TOSS Fields </td> </tr> <tr> <td colspan="3"> <asp:Panel ID="pnlTOSS" runat="server"> <table> <tr> <td colspan="3"><b>TOSS Specific Fields</b></td> </tr> <tr> <td class="spacer"> </td> <td align="right">Region:</td> <td> <asp:DropDownList ID="ddlAddBranchTOSSRegion" runat="server"> </asp:DropDownList> </td> </tr> <tr> <td class="spacer"> </td> <td align="right">Number of Tellers:</td> <td> <asp:TextBox ID="txtAddBranchTOSSNumTellers" runat="server" MaxLength="2"></asp:TextBox> <ajax:FilteredTextBoxExtender ID="ftxteAddBranchTOSSNumTellers" runat="server" TargetControlID="txtAddBranchTOSSNumTellers" FilterType="Numbers"> </ajax:FilteredTextBoxExtender> <asp:RequiredFieldValidator ID="rfvAddBranchTOSSNumTellers" runat="server" display="none" ErrorMessage="This field is required." ControlToValidate="txtAddBranchTOSSNumTellers"> </asp:RequiredFieldValidator> <ajax:ValidatorCalloutExtender ID="vceAddBranchTOSSNumTellers" runat="server" TargetControlID="rfvAddBranchTOSSNumTellers" HighlightCssClass="validateCallout"> </ajax:ValidatorCalloutExtender> </td> </tr> <tr> <td class="spacer"> </td> <td align="right">Sales FTE:</td> <td> <asp:TextBox ID="txtAddBranchTOSSSalesFTE" runat="server" MaxLength="7"></asp:TextBox> <ajax:FilteredTextBoxExtender ID="ftxteAddBranchTOSSSalesFTE" runat="server" TargetControlID="txtAddBranchTOSSSalesFTE" FilterType="Custom" ValidChars=".0123456789"> </ajax:FilteredTextBoxExtender> <asp:RequiredFieldValidator ID="rfvAddBranchTOSSSalesFTE" runat="server" display="none" ErrorMessage="This field is required." ControlToValidate="txtAddBranchTOSSSalesFTE"> </asp:RequiredFieldValidator> <ajax:ValidatorCalloutExtender ID="vceAddBranchTOSSSalesFTE" runat="server" TargetControlID="rfvAddBranchTOSSSalesFTE" HighlightCssClass="validateCallout"> </ajax:ValidatorCalloutExtender> </td> </tr> <tr> <td class="spacer"> </td> <td align="right">Effective Date:</td> <td> <asp:TextBox ID="txtAddBranchTOSSEffectiveDate" runat="server" MaxLength="10"> </asp:TextBox><asp:Image ID="imgCalendar" runat="server" ImageUrl="images/cldrimg.png" /> <ajax:FilteredTextBoxExtender ID="ftxteAddBranchTOSSEffectiveDate" runat="server" TargetControlID="txtAddBranchTOSSEffectiveDate" FilterType="custom" ValidChars="0123456789//"> </ajax:FilteredTextBoxExtender> <ajax:CalendarExtender ID="cldreAddBranchTOSSEffectiveDate" runat="server" TargetControlID="txtAddBranchTOSSEffectiveDate" Animated="true" PopupButtonID="imgCalendar"> </ajax:CalendarExtender> <asp:RequiredFieldValidator ID="rfvAddBranchTOSSEffectiveDate" runat="server" display="none" ErrorMessage="This field is required." ControlToValidate="txtAddBranchTOSSEffectiveDate"> </asp:RequiredFieldValidator> <ajax:ValidatorCalloutExtender ID="vceAddBranchTOSSEffectiveDate" runat="server" TargetControlID="rfvAddBranchTOSSEffectiveDate" HighlightCssClass="validateCallout"> </ajax:ValidatorCalloutExtender> </td> </tr> </table> </asp:Panel> </td> </tr> <tr> <td colspan="3"> <asp:CheckBox ID="cbTSFGu" runat="server" AutoPostBack="true" />Modify TSFGu Fields </td> </tr> <tr> <td colspan="3"> <asp:Panel ID="pnlTSFGu" runat="server"> <table> <tr> <td colspan="3"><b>TSFGu Specific Fields</b></td> </tr> <tr> <td class="spacer"> </td> <td align="right">Region:</td> <td> <asp:DropDownList ID="ddlAddBranchTSFGuRegion" runat="server"> </asp:DropDownList> </td> </tr> </table> </asp:Panel> </td> </tr> </table>


I was able to narrow it down to the ValidatorCallout causing the error.

I'm able to run the ddl one time to fill in the fields. It results in the error described above, but the fields fill in. If I try to select another branch from the dropdown list above, the error keeps the postback from going. So it's a one-shot deal, otherwise you have to reload.

Removing the updatepanel removes all of the errors and it works perfectly, but the tell-tale page flicker is back.

CalendarExtender Problem

Hi,

i have a problem with the CalendarExtender. i am trying to use this calendar in one of my projects and it is working fine excepting when i try to select a date for April. when the April month is selected all the days are 29. I tried to run the calendar from SampleWebSite that came with the Control toll kit and it is not working. it is the same problem.

This is the code that i am using :

<asp:TextBox ID="TextBox18" runat="server" ToolTip="" Style="width: auto; height: auto;"></asp:TextBox>
<asp:ImageButton runat="Server" ID="Image18" ImageUrl="../MediaFiles/Calendar_scheduleHS.png"
AlternateText="Click to show calendar" /><br />
<ajaxToolkit:CalendarExtender ID="calendarButtonExtender18" runat="server" TargetControlID="TextBox18"
PopupButtonID="Image18" />
 
Please help me.  

Hi,

I tried both your code and the sample web site, they worked fine.

Can you make sure that you didn't change related script by any chance? Please download the most recent version and try again.


We are marking this issue as "Answered". If you have any new findings or concerns, please feel free to unmark the issue.

sorry worng post

CalendarExtender not working

Hello.

I'm developing a web site in VS2005 Pro, Sp1, ASP2.0, WSE3.0, SQLServer Express 2005 on XP Pro, SP2.

I'm attempting to use the CalendarExtender from the AJAX Control Toolkit. My code showing the extender and the text box it is tied is below.

When i run the program, it does not popup a calendar when the text box get focus. It just functions as a normal textbox.

Is there another property i should set?

It seems pretty simple. Just assign the id of the text box to the TargetControlID of the extender.

Any help would be gratefully appreciated.

Thanks,
Tony

Sorry. I forgot this:

<%@.PageLanguage="VB"MasterPageFile="~/AppMaster.Master"CodeFile="GetTruckMileage.aspx.vb"Inherits="GetTruckMileage"title="Coyne Web Services - Get Truck Mileage" %>

<%@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="cc1" %>

<%@.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Namespace="System.Web.UI"TagPrefix="asp" %>

<asp:ContentID="Content1"ContentPlaceHolderID="mainCopy"runat="server">

<divclass="container">

<h1>Coyne Chemical Trips and Truck Mileage</h1>

<pclass="teaser">Coyne Chemical Trips and Truck Mileage from Xatanet.</p>

<br/>

<asp:LabelID="Label1"runat="server"Text="Start Date:"></asp:Label>
<asp:TextBoxID="startDateCalendar"runat="server"></asp:TextBox>

<br/>
<br/>

<asp:LabelID="Label2"runat="server"Text=" End Date:"></asp:Label>
<asp:TextBoxID="endDateCalendar"runat="server"></asp:TextBox>
<asp:ScriptManagerid="ScriptManager1"runat="server">
</asp:ScriptManager>

<cc1:CalendarExtenderID="startDateCalendarExtender"runat="server"TargetControlID="startDateCalendar">
</cc1:CalendarExtender>

<cc1:CalendarExtenderID="endDateCalendarExtender"runat="server"TargetControlID="endDateCalendar">
</cc1:CalendarExtender>

<div>

<br/>
<br/>

<asp:ButtonID="getTruckMileageButton"Text="Get Truck Mileage"runat="server"/> 
<asp:ButtonID="exportTripsButton"runat="server"Text="Export to HP3000"/> 

<br/>
<br/>

<asp:TextboxID="getTruckMileageCompletedTextbox"runat="server"ReadOnly="True"style="overflow: visible"TextMode="MultiLine"Width="360px"></asp:Textbox>

</div>

</div>


try putting the scriptmanager before the textboxes, as good practice you should always put it at the top of a page, ( i think i heard that somewhere :P)


Hello Cowboy.

That did not help.

Why do things look so simple and easy in demos and when other people use them. When i try something, it never works the way it is supposed to.

Maybe i don't know how to set up a development computer. Have other programmers run into this problem with the calendarextender?

Thanks,
Tony


i just did this and it works fine

<head runat="server"> <title>Untitled Page</title></head><body><form id="muy" runat="server"><div class="container"><h1>Coyne Chemical Trips and Truck Mileage</h1><p class="teaser">Coyne Chemical Trips and Truck Mileage from Xatanet.</p><br /><asp:Label ID="Label1" runat="server" Text="Start Date:"></asp:Label><asp:TextBox ID="startDateCalendar" runat="server" ></asp:TextBox>  <br /><br /> <asp:Label ID="Label2" runat="server" Text=" End Date:"></asp:Label><asp:TextBox ID="endDateCalendar" runat="server"></asp:TextBox><asp:ScriptManager id="ScriptManager1" runat="server"></asp:ScriptManager><cc1:CalendarExtender ID="startDateCalendarExtender" runat="server" TargetControlID="startDateCalendar"></cc1:CalendarExtender><cc1:CalendarExtender ID="endDateCalendarExtender" runat="server" TargetControlID="endDateCalendar"></cc1:CalendarExtender><div><br /><br /><asp:Button ID="getTruckMileageButton" Text="Get Truck Mileage" runat="server" />         <asp:Button ID="exportTripsButton" runat="server" Text="Export to HP3000" />  <br /><br /><asp:Textbox ID="getTruckMileageCompletedTextbox" runat="server" ReadOnly="True" style="overflow: visible" TextMode="MultiLine" Width="360px"></asp:Textbox></div> </div> </form></body></html>
i think there is an issue with how you have it in your container dealy

Well then. I must be pretty stupid.

If my code works for you, then there must be something seriously wrong with my computer. I could try it on other computers, but that requires more effort than the benefit i would realize. To me it's not worth it to go through a bunch of troubleshooting steps just to have a nice little popup for a date entry. I'm sure there are a lot of other troubleshooting steps too.

I can't figure it out. I guess that's the end of my attempts to put AJAX control toolkit to use.

Thanks,
Tony


i wouldnt give up on the toolkit just yet, it has great features, try to put the code i posted above in a new page and see if it works, there could be a compatibility issue because you were putting the controls inside a container of some kind (i forget how u had it set up) but the code i posted put it right on the form. Try it like that and see if the calendar works, then you will know if its an issue with the container (in which case you can find another way to hold the contorls, like a panel) or if its actually you computer. Usually if you have an issue with your computer you would see an error tho


I tried your code in another project and it worked ok.

So there is something in my project that is keeping it from working.

Thanks,
Tony


I think its a probelm with this

<asp:ContentID="Content1"ContentPlaceHolderID="mainCopy"runat="server">

ive never used this control so im not sure what is going on, but maybe try using a different control then this if u can.


I don't think i can use a different control. That control is tied to the master page.

I didn't see any warnings or notes in AJAX saying that it would not work with master pages and in fact, if AJAX is not compatible with master pages, then i can't use it anyway, because all of my projects use master pages.

Thanks,
Tony


ajax works with masterpages, it just takes a little effort from what ive heard. another option though is just using the standard asp.net calendar and putting it in its own <div> and using hide/show to make it display and use the selecteddate event to add the date they pic to your textbox. note a nice looking as ajax calendar with animation and stuff, but it gets the job done


Hello Cowboy.

I figured what the problem is. I should have watched this video before i started using AJAX.

I alao should have informed you that i was adding to an existing application.

Thanks for your help.
Tony

http://www.asp.net/learn/videos/view.aspx?tabid=63&id=81

How Do I: Add ASP.NET AJAX Features to an Existing Web Application?

CalendarExtender Not Working

I haven't read about this anywhere, but the CalendarExtender hasn't been working for me for some time.

I keep getting the following javascript error when i attempt to Pop it up:

Sys.ArgumentNullException:Value cannot be null. Parameter name: classNameI just picked up 14100 off of CodePlex and can confirm the same thing with the development branch.
As far as i can tell this began happening after the 11645 changes
There is a calendarextender?